aboutsummaryrefslogtreecommitdiff
path: root/src/huffman/huff.cpp
diff options
context:
space:
mode:
authorLadislav Zezula <ladislav.zezula@avg.com>2015-05-28 13:49:23 +0200
committerLadislav Zezula <ladislav.zezula@avg.com>2015-05-28 13:49:23 +0200
commit1b38ceb0d4bb4ae32cb93c295e3ef493b91f9a78 (patch)
tree5634e1d3fd17386975db1c0d4e95176db098bc1f /src/huffman/huff.cpp
parentc26e12c79f2a5e0c092de4a62565bdae4bf5a7dd (diff)
+ Fixed defects found by Coverity (well, most of them)
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