avcodec/mpc8: init avctx->sample_rate

Fixes frame validation.

Fixes: 416134551/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPC8_fuzzer-5765557242888192
Found-by: OSS-Fuzz
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
This commit is contained in:
Kacper Michajłow 2025-08-06 19:49:11 +02:00
parent fb862976df
commit 09cb2d41d1

View file

@ -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);