[FFmpeg-cvslog] avcodec/ac3dec: Check operations that can fail
Andreas Rheinhardt
git at videolan.org
Sat Jan 9 05:44:06 EET 2021
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Thu Dec 3 16:04:13 2020 +0100| [10663312de979404d2417a120a3c85a68cf70dd5] | committer: Andreas Rheinhardt
avcodec/ac3dec: Check operations that can fail
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=10663312de979404d2417a120a3c85a68cf70dd5
---
libavcodec/ac3dec.c | 11 +++++++----
libavcodec/ac3dec_fixed.c | 1 +
libavcodec/ac3dec_float.c | 2 ++
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index eaa327a3ee..3e4bec56b1 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -184,22 +184,25 @@ static av_cold void ac3_tables_init(void)
static av_cold int ac3_decode_init(AVCodecContext *avctx)
{
AC3DecodeContext *s = avctx->priv_data;
- int i;
+ int i, ret;
s->avctx = avctx;
ac3_tables_init();
- ff_mdct_init(&s->imdct_256, 8, 1, 1.0);
- ff_mdct_init(&s->imdct_512, 9, 1, 1.0);
+ if ((ret = ff_mdct_init(&s->imdct_256, 8, 1, 1.0)) < 0 ||
+ (ret = ff_mdct_init(&s->imdct_512, 9, 1, 1.0)) < 0)
+ return ret;
AC3_RENAME(ff_kbd_window_init)(s->window, 5.0, 256);
ff_bswapdsp_init(&s->bdsp);
#if (USE_FIXED)
s->fdsp = avpriv_alloc_fixed_dsp(avctx->flags & AV_CODEC_FLAG_BITEXACT);
#else
- s->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
ff_fmt_convert_init(&s->fmt_conv, avctx);
+ s->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
#endif
+ if (!s->fdsp)
+ return AVERROR(ENOMEM);
ff_ac3dsp_init(&s->ac3dsp, avctx->flags & AV_CODEC_FLAG_BITEXACT);
av_lfg_init(&s->dith_state, 0);
diff --git a/libavcodec/ac3dec_fixed.c b/libavcodec/ac3dec_fixed.c
index f36854cdc5..662cb8169e 100644
--- a/libavcodec/ac3dec_fixed.c
+++ b/libavcodec/ac3dec_fixed.c
@@ -182,4 +182,5 @@ AVCodec ff_ac3_fixed_decoder = {
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
AV_SAMPLE_FMT_NONE },
.priv_class = &ac3_decoder_class,
+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
};
diff --git a/libavcodec/ac3dec_float.c b/libavcodec/ac3dec_float.c
index 57a626a181..5010ee0ca5 100644
--- a/libavcodec/ac3dec_float.c
+++ b/libavcodec/ac3dec_float.c
@@ -67,6 +67,7 @@ AVCodec ff_ac3_decoder = {
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
AV_SAMPLE_FMT_NONE },
.priv_class = &ac3_decoder_class,
+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
};
#if CONFIG_EAC3_DECODER
@@ -91,5 +92,6 @@ AVCodec ff_eac3_decoder = {
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
AV_SAMPLE_FMT_NONE },
.priv_class = &eac3_decoder_class,
+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
};
#endif
More information about the ffmpeg-cvslog
mailing list