diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c index e4cef61811..388d8dee78 100644 --- a/libavcodec/shorten.c +++ b/libavcodec/shorten.c @@ -155,8 +155,11 @@ static int allocate_buffers(ShortenContext *s) static inline unsigned int get_uint(ShortenContext *s, int k) { - if (s->version != 0) + if (s->version != 0) { k = get_ur_golomb_shorten(&s->gb, ULONGSIZE); + if (k > 31U) + return AVERROR_INVALIDDATA; + } return get_ur_golomb_shorten(&s->gb, k); }