]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/smacker: Use unsigned for shift
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Thu, 30 Jul 2020 11:20:09 +0000 (13:20 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Thu, 17 Sep 2020 23:47:57 +0000 (01:47 +0200)
Given that the code currently accepts only 27 bits long Huffman codes,
the shift 1 << (length - 1) with length in 1..28 that is performed when
parsing the tree is safe. Yet if this limit were ever expanded to the
full 32 bits, this shift would be potentially undefined. So simply use
unsigned.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavcodec/smacker.c

index 9ba70af6f703e8d21671f4cf60fa92076d832e69..e6b163722a4c332820e8105faa0ba2f7cd13f351 100644 (file)
@@ -121,7 +121,7 @@ static int smacker_decode_tree(GetBitContext *gb, HuffContext *hc, uint32_t pref
         r = smacker_decode_tree(gb, hc, prefix, length);
         if(r)
             return r;
-        return smacker_decode_tree(gb, hc, prefix | (1 << (length - 1)), length);
+        return smacker_decode_tree(gb, hc, prefix | (1U << (length - 1)), length);
     }
 }