MCPcopy Create free account
hub / github.com/DFHack/dfhack / LodePNGBitReader_init

Function LodePNGBitReader_init

depends/lodepng/lodepng.cpp:465–477  ·  view source on GitHub ↗

data size argument is in bytes. Returns error if size too large causing overflow */

Source from the content-addressed store, hash-verified

463
464/* data size argument is in bytes. Returns error if size too large causing overflow */
465static unsigned LodePNGBitReader_init(LodePNGBitReader* reader, const unsigned char* data, size_t size) {
466 size_t temp;
467 reader->data = data;
468 reader->size = size;
469 /* size in bits, return error if overflow (if size_t is 32 bit this supports up to 500MB) */
470 if(lodepng_mulofl(size, 8u, &reader->bitsize)) return 105;
471 /*ensure incremented bp can be compared to bitsize without overflow even when it would be incremented 32 too much and
472 trying to ensure 32 more bits*/
473 if(lodepng_addofl(reader->bitsize, 64u, &temp)) return 105;
474 reader->bp = 0;
475 reader->buffer = 0;
476 return 0; /*ok*/
477}
478
479/*
480ensureBits functions:

Callers 2

lode_png_test_bitreaderFunction · 0.85
lodepng_inflatevFunction · 0.85

Calls 2

lodepng_muloflFunction · 0.85
lodepng_addoflFunction · 0.85

Tested by

no test coverage detected