[FFmpeg-cvslog] avcodec/smacker: Use unsigned for shift

Andreas Rheinhardt git at videolan.org
Fri Sep 18 03:31:51 EEST 2020


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Thu Jul 30 13:20:09 2020 +0200| [01dbcbb37a30b77dcdc7b2d9ed6a4fcccf4f4eec] | committer: Andreas Rheinhardt

avcodec/smacker: Use unsigned for shift

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 at gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=01dbcbb37a30b77dcdc7b2d9ed6a4fcccf4f4eec
---

 libavcodec/smacker.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c
index 9ba70af6f7..e6b163722a 100644
--- a/libavcodec/smacker.c
+++ b/libavcodec/smacker.c
@@ -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);
     }
 }
 



More information about the ffmpeg-cvslog mailing list