diff options
author | Lode <lvandeve@gmail.com> | 2022-06-18 17:43:31 +0300 |
---|---|---|
committer | Lode <lvandeve@gmail.com> | 2022-06-18 17:43:31 +0300 |
commit | 08a7cd132311f5b98c30657af1dc6d72ec8f0a50 (patch) | |
tree | 8da6de7a0a09798186baf3dce82fac47d1202791 | |
parent | 43d56186f9da45d72373ba1cca8f8b347ccec635 (diff) |
small fixes
-rw-r--r-- | lodepng.cpp | 9 | ||||
-rw-r--r-- | lodepng_unittest.cpp | 1 |
2 files changed, 6 insertions, 4 deletions
diff --git a/lodepng.cpp b/lodepng.cpp index 3cc0160..c2305a0 100644 --- a/lodepng.cpp +++ b/lodepng.cpp @@ -711,10 +711,11 @@ static unsigned HuffmanTree_makeTable(HuffmanTree* tree) { numpresent = 0; for(i = 0; i < tree->numcodes; ++i) { unsigned l = tree->lengths[i]; + unsigned symbol, reverse; if(l == 0) continue; - unsigned symbol = tree->codes[i]; /*the huffman bit pattern. i itself is the value.*/ + symbol = tree->codes[i]; /*the huffman bit pattern. i itself is the value.*/ /*reverse bits, because the huffman bits are given in MSB first order but the bit reader reads LSB first*/ - unsigned reverse = reverseBits(symbol, l); + reverse = reverseBits(symbol, l); numpresent++; if(l <= FIRSTBITS) { @@ -1367,8 +1368,8 @@ static unsigned inflateNoCompression(ucvector* out, LodePNGBitReader* reader, /*read the literal data: LEN bytes are now stored in the out buffer*/ if(bytepos + LEN > size) return 23; /*error: reading outside of in buffer*/ - /*out->data can be NULL (when LEN is zero), and arithmetics on NULL ptr is undefined. so we check*/ - if (out->data) { + /*out->data can be NULL (when LEN is zero), and arithmetics on NULL ptr is undefined*/ + if (LEN) { lodepng_memcpy(out->data + out->size - LEN, reader->data + bytepos, LEN); bytepos += LEN; } diff --git a/lodepng_unittest.cpp b/lodepng_unittest.cpp index a742e05..13a4e69 100644 --- a/lodepng_unittest.cpp +++ b/lodepng_unittest.cpp @@ -65,6 +65,7 @@ g++ lodepng.cpp lodepng_util.cpp pngdetail.cpp -Werror -W -Wall -ansi -pedantic ./pngdetail testdata/PngSuite/basi0g01.png *) Test compiling with some code sections with #defines disabled, for unused static function warnings etc... +g++ lodepng.cpp -W -Wall -ansi -pedantic -O3 -c -DLODEPNG_NO_COMPILE_CRC g++ lodepng.cpp -W -Wall -ansi -pedantic -O3 -c -DLODEPNG_NO_COMPILE_ZLIB g++ lodepng.cpp -W -Wall -ansi -pedantic -O3 -c -DLODEPNG_NO_COMPILE_PNG g++ lodepng.cpp -W -Wall -ansi -pedantic -O3 -c -DLODEPNG_NO_COMPILE_DECODER |