]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/cngenc: Cleanup generically after init failure
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Mon, 14 Sep 2020 00:00:11 +0000 (02:00 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Fri, 18 Sep 2020 00:51:31 +0000 (02:51 +0200)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavcodec/cngenc.c

index 8f23b7555a2c6fa721fb4e67d449591f3a276b92..b622d7bbdab57096c6dd05a9d5ce0b5550b5dd9d 100644 (file)
@@ -58,10 +58,8 @@ static av_cold int cng_encode_init(AVCodecContext *avctx)
         return ret;
     p->samples32 = av_malloc_array(avctx->frame_size, sizeof(*p->samples32));
     p->ref_coef = av_malloc_array(p->order, sizeof(*p->ref_coef));
-    if (!p->samples32 || !p->ref_coef) {
-        cng_encode_close(avctx);
+    if (!p->samples32 || !p->ref_coef)
         return AVERROR(ENOMEM);
-    }
 
     return 0;
 }
@@ -113,4 +111,5 @@ AVCodec ff_comfortnoise_encoder = {
     .close          = cng_encode_close,
     .sample_fmts    = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16,
                                                      AV_SAMPLE_FMT_NONE },
+    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };