Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/lvandeve/lodepng.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@gmail.com>2022-06-17 22:20:06 +0300
committerGitHub <noreply@github.com>2022-06-17 22:20:06 +0300
commit8242b9a544be21321ff987e0e6fa51a02c36e577 (patch)
tree54ba4712a1f4402e1b3c8216e7be8ce17bb3dfab
parent71064f28b6ac8283a3fc529aa5b67f6c027293f7 (diff)
Continue early to avoid uninitialized value
If l == 0 we don't need to load symbol and call reverseBits. However if we do, symbol is uninitialized and function call with uninitialized argument and behavior is undefined.
-rw-r--r--lodepng.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/lodepng.cpp b/lodepng.cpp
index 466bcc5..a5a1f5f 100644
--- a/lodepng.cpp
+++ b/lodepng.cpp
@@ -711,10 +711,10 @@ static unsigned HuffmanTree_makeTable(HuffmanTree* tree) {
numpresent = 0;
for(i = 0; i < tree->numcodes; ++i) {
unsigned l = tree->lengths[i];
+ if(l == 0) continue;
unsigned 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);
- if(l == 0) continue;
numpresent++;
if(l <= FIRSTBITS) {