]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/mss3: Cleanup generically after init failure
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Sat, 29 Aug 2020 06:51:55 +0000 (08:51 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Sun, 30 Aug 2020 00:59:08 +0000 (02:59 +0200)
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavcodec/mss3.c

index a301675ec293261d26f067c36c63912d0103bcf9..74f4b5e6712b1a846a48d7907b1c25d4e254924c 100644 (file)
@@ -844,19 +844,13 @@ static av_cold int mss3_decode_init(AVCodecContext *avctx)
                                             b_width * b_height);
         if (!c->dct_coder[i].prev_dc) {
             av_log(avctx, AV_LOG_ERROR, "Cannot allocate buffer\n");
-            while (i >= 0) {
-                av_freep(&c->dct_coder[i].prev_dc);
-                i--;
-            }
             return AVERROR(ENOMEM);
         }
     }
 
     c->pic = av_frame_alloc();
-    if (!c->pic) {
-        mss3_decode_end(avctx);
+    if (!c->pic)
         return AVERROR(ENOMEM);
-    }
 
     avctx->pix_fmt     = AV_PIX_FMT_YUV420P;
 
@@ -875,4 +869,5 @@ AVCodec ff_msa1_decoder = {
     .close          = mss3_decode_end,
     .decode         = mss3_decode_frame,
     .capabilities   = AV_CODEC_CAP_DR1,
+    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };