[FFmpeg-devel] [PATCH] avcodec/dcaenc: fix memory leaks on init failure

foo86 foobaz86 at gmail.com
Mon Jul 24 22:46:33 EEST 2017


---
 libavcodec/dcaenc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/dcaenc.c b/libavcodec/dcaenc.c
index 37095674f5..1740c16432 100644
--- a/libavcodec/dcaenc.c
+++ b/libavcodec/dcaenc.c
@@ -145,8 +145,8 @@ static int subband_bufer_alloc(DCAEncContext *c)
 
 static void subband_bufer_free(DCAEncContext *c)
 {
-    int32_t *bufer = c->subband[0][0] - DCA_ADPCM_COEFFS;
-    av_freep(&bufer);
+    if (c->subband[0][0])
+        av_free(c->subband[0][0] - DCA_ADPCM_COEFFS);
 }
 
 static int encode_init(AVCodecContext *avctx)
@@ -1298,4 +1298,5 @@ AVCodec ff_dca_encoder = {
                                                   0 },
     .defaults              = defaults,
     .priv_class            = &dcaenc_class,
+    .caps_internal         = FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.11.0



More information about the ffmpeg-devel mailing list