avcodec/flacdec: make while get_bits loop more robust by checking bits left
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 30 Oct 2013 13:23:30 +0000 (14:23 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 30 Oct 2013 13:39:31 +0000 (14:39 +0100)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/flacdec.c

index 9bf950a..95623cb 100644 (file)
@@ -366,8 +366,11 @@ static inline int decode_subframe(FLACContext *s, int channel)
                    bps, left);
             return AVERROR_INVALIDDATA;
         }
-        while (!get_bits1(&s->gb))
+        while (!get_bits1(&s->gb)) {
             wasted++;
+            if (get_bits_left(&s->gb) <= 0)
+                return AVERROR_INVALIDDATA;
+        }
         bps -= wasted;
     }
     if (bps > 32) {