1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-15 14:13:16 +02:00

avcodec/wmadec: Check operations that can fail

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2021-05-06 17:28:50 +02:00
parent 35381d2201
commit bd1cbb5427

View File

@@ -106,20 +106,31 @@ static av_cold int wma_decode_init(AVCodecContext *avctx)
return ret; return ret;
/* init MDCT */ /* init MDCT */
for (i = 0; i < s->nb_block_sizes; i++) for (i = 0; i < s->nb_block_sizes; i++) {
ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 1, 1.0 / 32768.0); ret = ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1,
1, 1.0 / 32768.0);
if (s->use_noise_coding) { if (ret < 0)
ff_init_vlc_from_lengths(&s->hgain_vlc, HGAINVLCBITS, FF_ARRAY_ELEMS(ff_wma_hgain_hufftab), return ret;
&ff_wma_hgain_hufftab[0][1], 2,
&ff_wma_hgain_hufftab[0][0], 2, 1, -18, 0, avctx);
} }
if (s->use_exp_vlc) if (s->use_noise_coding) {
init_vlc(&s->exp_vlc, EXPVLCBITS, sizeof(ff_aac_scalefactor_bits), // FIXME move out of context ret = ff_init_vlc_from_lengths(&s->hgain_vlc, HGAINVLCBITS,
FF_ARRAY_ELEMS(ff_wma_hgain_hufftab),
&ff_wma_hgain_hufftab[0][1], 2,
&ff_wma_hgain_hufftab[0][0], 2, 1,
-18, 0, avctx);
if (ret < 0)
return ret;
}
if (s->use_exp_vlc) {
// FIXME move out of context
ret = init_vlc(&s->exp_vlc, EXPVLCBITS, sizeof(ff_aac_scalefactor_bits),
ff_aac_scalefactor_bits, 1, 1, ff_aac_scalefactor_bits, 1, 1,
ff_aac_scalefactor_code, 4, 4, 0); ff_aac_scalefactor_code, 4, 4, 0);
else if (ret < 0)
return ret;
} else
wma_lsp_to_curve_init(s, s->frame_len); wma_lsp_to_curve_init(s, s->frame_len);
avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;