diff mbox series

[FFmpeg-devel,08/30] avcodec/hcom: Cleanup generically upon init failure

Message ID 20200915074000.102622-8-andreas.rheinhardt@gmail.com
State Accepted
Commit 0bb5cc0ee959bdc2ff439a149343bc1a53998f31
Headers show
Series [FFmpeg-devel,01/30] avcodec/flashsvenc: Avoid allocation of buffer, fix memleak | expand

Checks

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

Commit Message

Andreas Rheinhardt Sept. 15, 2020, 7:39 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/hcom.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

Comments

Paul B Mahol Sept. 15, 2020, 9:07 a.m. UTC | #1
On Tue, Sep 15, 2020 at 09:39:38AM +0200, Andreas Rheinhardt wrote:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavcodec/hcom.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)

probably ok

> 
> diff --git a/libavcodec/hcom.c b/libavcodec/hcom.c
> index 8300676f98..06fa25fcd2 100644
> --- a/libavcodec/hcom.c
> +++ b/libavcodec/hcom.c
> @@ -67,15 +67,11 @@ static av_cold int hcom_init(AVCodecContext *avctx)
>          if (s->dict[i].l >= 0 &&
>              (s->dict[i].l >= s->dict_entries ||
>               s->dict[i].r >= s->dict_entries ||
> -             s->dict[i].r < 0 )) {
> -            av_freep(&s->dict);
> +             s->dict[i].r < 0 ))
>              return AVERROR_INVALIDDATA;
> -        }
>      }
> -    if (s->dict[0].l < 0) {
> -        av_freep(&s->dict);
> +    if (s->dict[0].l < 0)
>          return AVERROR_INVALIDDATA;
> -    }
>  
>      avctx->sample_fmt = AV_SAMPLE_FMT_U8;
>      s->dict_entry = 0;
> @@ -148,4 +144,5 @@ AVCodec ff_hcom_decoder = {
>      .close          = hcom_close,
>      .decode         = hcom_decode,
>      .capabilities   = AV_CODEC_CAP_DR1,
> +    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
>  };
> -- 
> 2.25.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/hcom.c b/libavcodec/hcom.c
index 8300676f98..06fa25fcd2 100644
--- a/libavcodec/hcom.c
+++ b/libavcodec/hcom.c
@@ -67,15 +67,11 @@  static av_cold int hcom_init(AVCodecContext *avctx)
         if (s->dict[i].l >= 0 &&
             (s->dict[i].l >= s->dict_entries ||
              s->dict[i].r >= s->dict_entries ||
-             s->dict[i].r < 0 )) {
-            av_freep(&s->dict);
+             s->dict[i].r < 0 ))
             return AVERROR_INVALIDDATA;
-        }
     }
-    if (s->dict[0].l < 0) {
-        av_freep(&s->dict);
+    if (s->dict[0].l < 0)
         return AVERROR_INVALIDDATA;
-    }
 
     avctx->sample_fmt = AV_SAMPLE_FMT_U8;
     s->dict_entry = 0;
@@ -148,4 +144,5 @@  AVCodec ff_hcom_decoder = {
     .close          = hcom_close,
     .decode         = hcom_decode,
     .capabilities   = AV_CODEC_CAP_DR1,
+    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };