summaryrefslogtreecommitdiff
path: root/libavcodec/cbs.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/cbs.c')
-rw-r--r--libavcodec/cbs.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index 10943164da..7440914939 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -313,6 +313,12 @@ int ff_cbs_read_unsigned(CodedBitstreamContext *ctx, BitstreamContext *bc,
av_assert0(width <= 32);
+ if (bitstream_bits_left(bc) < width) {
+ av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid value at "
+ "%s: bitstream ended.\n", name);
+ return AVERROR_INVALIDDATA;
+ }
+
if (ctx->trace_enable)
position = bitstream_tell(bc);