diff mbox series

[FFmpeg-devel,05/13] avcodec/mss3: Cleanup generically after init failure

Message ID 20200829175626.11682-5-andreas.rheinhardt@gmail.com
State Accepted
Commit 3a76076513c7e817afba7f318b5f0ea20de40e5e
Headers show
Series [FFmpeg-devel,01/13] avcodec/cinepakenc: Cleanup generically after init failure
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Aug. 29, 2020, 5:56 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/mss3.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

Comments

Paul B Mahol Aug. 29, 2020, 8:39 p.m. UTC | #1
On 8/29/20, Andreas Rheinhardt <andreas.rheinhardt@gmail.com> wrote:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavcodec/mss3.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
>

LGTM

> diff --git a/libavcodec/mss3.c b/libavcodec/mss3.c
> index a301675ec2..74f4b5e671 100644
> --- a/libavcodec/mss3.c
> +++ b/libavcodec/mss3.c
> @@ -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,
>  };
> --
> 2.20.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

diff --git a/libavcodec/mss3.c b/libavcodec/mss3.c
index a301675ec2..74f4b5e671 100644
--- a/libavcodec/mss3.c
+++ b/libavcodec/mss3.c
@@ -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,
 };