aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-12-03 16:04:13 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2021-01-09 04:06:32 +0100
commit10663312de979404d2417a120a3c85a68cf70dd5 (patch)
tree90ca8dfb6a37c7c47baa4cdd1950b2c2e3b8a5ec /libavcodec
parent277281ac8eb7337a8d6dbddc9ffcfffabe44b40c (diff)
downloadffmpeg-10663312de979404d2417a120a3c85a68cf70dd5.tar.gz
avcodec/ac3dec: Check operations that can fail
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/ac3dec.c11
-rw-r--r--libavcodec/ac3dec_fixed.c1
-rw-r--r--libavcodec/ac3dec_float.c2
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