diff mbox

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

Message ID 20170724194633.11925-1-foobaz86@gmail.com
State New
Headers show

Commit Message

foo86 July 24, 2017, 7:46 p.m. UTC
---
 libavcodec/dcaenc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox

Patch

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,
 };