diff mbox series

[FFmpeg-devel,72/72] avcodec/pafvideo: Cleanup generically on init failure

Message ID 20201127174652.2838198-27-andreas.rheinhardt@gmail.com
State Accepted
Commit 7eb9cf593e33dfdb1127d325d25a93c4c52b59d7
Headers show
Series [FFmpeg-devel,01/45] avcodec/a64multienc: Fix memleak upon init failure | expand

Checks

Context Check Description
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Nov. 27, 2020, 5:46 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/pafvideo.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Paul B Mahol Nov. 27, 2020, 5:52 p.m. UTC | #1
LGTM

On Fri, Nov 27, 2020 at 6:52 PM Andreas Rheinhardt <
andreas.rheinhardt@gmail.com> wrote:

> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavcodec/pafvideo.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/libavcodec/pafvideo.c b/libavcodec/pafvideo.c
> index 22ae26ac10..1e5d891332 100644
> --- a/libavcodec/pafvideo.c
> +++ b/libavcodec/pafvideo.c
> @@ -104,10 +104,8 @@ static av_cold int paf_video_init(AVCodecContext
> *avctx)
>      c->video_size = avctx->width * avctx->height;
>      for (i = 0; i < 4; i++) {
>          c->frame[i] = av_mallocz(c->frame_size);
> -        if (!c->frame[i]) {
> -            paf_video_close(avctx);
> +        if (!c->frame[i])
>              return AVERROR(ENOMEM);
> -        }
>      }
>
>      return 0;
> @@ -419,5 +417,5 @@ AVCodec ff_paf_video_decoder = {
>      .close          = paf_video_close,
>      .decode         = paf_video_decode,
>      .capabilities   = AV_CODEC_CAP_DR1,
> -    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
> +    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE |
> 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/pafvideo.c b/libavcodec/pafvideo.c
index 22ae26ac10..1e5d891332 100644
--- a/libavcodec/pafvideo.c
+++ b/libavcodec/pafvideo.c
@@ -104,10 +104,8 @@  static av_cold int paf_video_init(AVCodecContext *avctx)
     c->video_size = avctx->width * avctx->height;
     for (i = 0; i < 4; i++) {
         c->frame[i] = av_mallocz(c->frame_size);
-        if (!c->frame[i]) {
-            paf_video_close(avctx);
+        if (!c->frame[i])
             return AVERROR(ENOMEM);
-        }
     }
 
     return 0;
@@ -419,5 +417,5 @@  AVCodec ff_paf_video_decoder = {
     .close          = paf_video_close,
     .decode         = paf_video_decode,
     .capabilities   = AV_CODEC_CAP_DR1,
-    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
+    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };