diff --git a/libavcodec/mpc8.c b/libavcodec/mpc8.c index 2785259119..ae145927ee 100644 --- a/libavcodec/mpc8.c +++ b/libavcodec/mpc8.c @@ -155,7 +155,13 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx) init_get_bits(&gb, avctx->extradata, 16); - skip_bits(&gb, 3);//sample rate + uint8_t sample_rate_idx = get_bits(&gb, 3); + static const int sample_rates[] = { 44100, 48000, 37800, 32000 }; + if (sample_rate_idx >= FF_ARRAY_ELEMS(sample_rates)) { + av_log(avctx, AV_LOG_ERROR, "invalid sample rate index (%u)\n", sample_rate_idx); + return AVERROR_INVALIDDATA; + } + avctx->sample_rate = sample_rates[sample_rate_idx]; c->maxbands = get_bits(&gb, 5) + 1; if (c->maxbands >= BANDS) { av_log(avctx,AV_LOG_ERROR, "maxbands %d too high\n", c->maxbands);