[FFmpeg-cvslog] avcodec/utvideodec: Fix undefined behavior in shift

Michael Niedermayer git at videolan.org
Tue Nov 11 03:46:47 CET 2014


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Tue Nov 11 03:34:58 2014 +0100| [48efe9ec86acf6dcf6aabef2114f8dd04e4fbce4] | committer: Michael Niedermayer

avcodec/utvideodec: Fix undefined behavior in shift

Fixes: asan_heap-oob_2573085_3783_utvideo_rgba_median.avi
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavcodec/utvideodec.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/utvideodec.c b/libavcodec/utvideodec.c
index 05c943f..b565c10 100644
--- a/libavcodec/utvideodec.c
+++ b/libavcodec/utvideodec.c
@@ -56,13 +56,14 @@ static int build_huff(const uint8_t *src, VLC *vlc, int *fsym)
         *fsym = he[0].sym;
         return 0;
     }
-    if (he[0].len > 32)
-        return -1;
 
     last = 255;
     while (he[last].len == 255 && last)
         last--;
 
+    if (he[last].len > 32)
+        return -1;
+
     code = 1;
     for (i = last; i >= 0; i--) {
         codes[i] = code >> (32 - he[i].len);



More information about the ffmpeg-cvslog mailing list