]> git.sesse.net Git - ffmpeg/commitdiff
on2avc: limit number of bits to 30 in get_egolomb
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Wed, 16 Dec 2015 15:48:19 +0000 (16:48 +0100)
committerAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Fri, 18 Dec 2015 14:29:57 +0000 (15:29 +0100)
More don't fit into the integer output.

Also use get_bits_long, since get_bits only supports reading up to 25
bits, while get_bits_long supports the full integer range.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
libavcodec/on2avc.c

index 15f4dd1c66ebaffa3fd271414864b5340f35baf0..04c8e410a8b5495d32b6d4659c8eca63547b9a77 100644 (file)
@@ -211,9 +211,16 @@ static inline int get_egolomb(GetBitContext *gb)
 {
     int v = 4;
 
-    while (get_bits1(gb)) v++;
+    while (get_bits1(gb)) {
+        v++;
+        if (v > 30) {
+            av_log(NULL, AV_LOG_WARNING, "Too large golomb code in get_egolomb.\n");
+            v = 30;
+            break;
+        }
+    }
 
-    return (1 << v) + get_bits(gb, v);
+    return (1 << v) + get_bits_long(gb, v);
 }
 
 static int on2avc_decode_pairs(On2AVCContext *c, GetBitContext *gb, float *dst,