diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c index 085020938a..832ba4c111 100644 --- a/libavcodec/vc1.c +++ b/libavcodec/vc1.c @@ -614,7 +614,13 @@ static void rotate_luts(VC1Context *v) } static int read_bfraction(VC1Context *v, GetBitContext* gb) { - v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1); + int bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1); + + if (bfraction_lut_index == 21 || bfraction_lut_index < 0) { + av_log(v->s.avctx, AV_LOG_ERROR, "bfraction invalid\n"); + return AVERROR_INVALIDDATA; + } + v->bfraction_lut_index = bfraction_lut_index; v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index]; return 0; }