[FFmpeg-devel] [PATCH] avcodec/ac3enc_float: fix fdsp memory leak

Paul B Mahol onemda at gmail.com
Thu Oct 17 12:20:01 EEST 2019


Fixes #8294

Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
 libavcodec/ac3enc_float.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c
index d6e658b2b4..18df313c1a 100644
--- a/libavcodec/ac3enc_float.c
+++ b/libavcodec/ac3enc_float.c
@@ -132,10 +132,16 @@ av_cold int ff_ac3_float_mdct_init(AC3EncodeContext *s)
 av_cold int ff_ac3_float_encode_init(AVCodecContext *avctx)
 {
     AC3EncodeContext *s = avctx->priv_data;
+    int ret = ff_ac3_encode_init(avctx);
+
+    if (ret < 0)
+        return ret;
     s->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
-    if (!s->fdsp)
+    if (!s->fdsp) {
+        ff_ac3_encode_close(avctx);
         return AVERROR(ENOMEM);
-    return ff_ac3_encode_init(avctx);
+    }
+    return 0;
 }
 
 AVCodec ff_ac3_encoder = {
-- 
2.17.1



More information about the ffmpeg-devel mailing list