]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/vb: Cleanup generically after init failure
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Sun, 13 Sep 2020 01:51:23 +0000 (03:51 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Wed, 16 Sep 2020 22:09:08 +0000 (00:09 +0200)
In other words: Set the FF_CODEC_CAP_INIT_CLEANUP flag.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavcodec/vb.c

index d9c6b93a7376fa5e5467703e069bfab56e8ff733..fe419c766313a58c51a381d4874d46dee7afb148 100644 (file)
@@ -262,11 +262,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
     c->frame      = av_mallocz(avctx->width * avctx->height);
     c->prev_frame = av_mallocz(avctx->width * avctx->height);
 
-    if (!c->frame || !c->prev_frame) {
-        av_freep(&c->frame);
-        av_freep(&c->prev_frame);
+    if (!c->frame || !c->prev_frame)
         return AVERROR(ENOMEM);
-    }
 
     return 0;
 }
@@ -291,4 +288,5 @@ AVCodec ff_vb_decoder = {
     .close          = decode_end,
     .decode         = decode_frame,
     .capabilities   = AV_CODEC_CAP_DR1,
+    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };