aboutsummaryrefslogtreecommitdiff
path: root/src/huffman/huff.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/huffman/huff.cpp')
-rw-r--r--src/huffman/huff.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/huffman/huff.cpp b/src/huffman/huff.cpp
index c973580..1636a80 100644
--- a/src/huffman/huff.cpp
+++ b/src/huffman/huff.cpp
@@ -409,7 +409,10 @@ THuffmannTree::THuffmannTree(bool bCompression)
pFirst = pLast = LIST_HEAD();
MinValidValue = 1;
ItemsUsed = 0;
-
+ bIsCmp0 = 0;
+
+ memset(ItemsByByte, 0, sizeof(ItemsByByte));
+
// If we are going to decompress data, we need to invalidate all item links
// We do so by zeroing their ValidValue, so it becomes lower MinValidValue
if(bCompression == false)
@@ -737,7 +740,8 @@ unsigned int THuffmannTree::DecodeOneByte(TInputStream * is)
else
{
// Limit the quick-decompress item to lower amount of bits
- ItemLinkIndex &= (0xFFFFFFFF >> (32 - BitCount));
+ // Coverity fix 84457: (x >> 32) has undefined behavior
+ ItemLinkIndex = (BitCount != 0) ? ItemLinkIndex & (0xFFFFFFFF >> (32 - BitCount)) : 0;
while(ItemLinkIndex < LINK_ITEM_COUNT)
{
// Fill the quick-decompress item