diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index 82345cd49d..2a5cee17ed 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -497,6 +497,10 @@ static void ac3_decode_transform_coeffs_ch(AC3DecodeContext *s, int ch_index, ma break; default: /* 6 to 15 */ /* Shift mantissa and sign-extend it. */ + if (bap > 15) { + av_log(s->avctx, AV_LOG_ERROR, "bap %d is invalid in plain AC-3\n", bap); + bap = 15; + } mantissa = get_sbits(gbc, quantization_tab[bap]); mantissa <<= 24 - quantization_tab[bap]; break;