summaryrefslogtreecommitdiff
path: root/libavcodec/cbs_mpeg2.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/cbs_mpeg2.c')
-rw-r--r--libavcodec/cbs_mpeg2.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libavcodec/cbs_mpeg2.c b/libavcodec/cbs_mpeg2.c
index fede3ff471..cbee42e905 100644
--- a/libavcodec/cbs_mpeg2.c
+++ b/libavcodec/cbs_mpeg2.c
@@ -58,8 +58,9 @@
CHECK(ff_cbs_read_unsigned(ctx, rw, 1, "marker_bit", &one, 1, 1)); \
} while (0)
-#define nextbits(width, compare, var) (var = bitstream_peek(rw, width), \
- var == (compare))
+#define nextbits(width, compare, var) \
+ (bitstream_bits_left(rw) >= width && \
+ (var = bitstream_peek(rw, width)) == (compare))
#include "cbs_mpeg2_syntax_template.c"