diff mbox series

[FFmpeg-devel,19/30] avcodec/magicyuvenc: Fix memleak upon init failure

Message ID 20200915074000.102622-19-andreas.rheinhardt@gmail.com
State Accepted
Commit a8ebb5632018adad733f89fa4efe74d7e92155ac
Headers show
Series [FFmpeg-devel,01/30] avcodec/flashsvenc: Avoid allocation of buffer, fix memleak
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 Sept. 15, 2020, 7:39 a.m. UTC
If an error happens during init after an allocation has succeeded,
the already allocated data leaked up until now. Fix this by setting the
FF_CODEC_CAP_INIT_CLEANUP flag.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/magicyuvenc.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Paul B Mahol Sept. 15, 2020, 9:08 a.m. UTC | #1
On Tue, Sep 15, 2020 at 09:39:49AM +0200, Andreas Rheinhardt wrote:
> If an error happens during init after an allocation has succeeded,
> the already allocated data leaked up until now. Fix this by setting the
> FF_CODEC_CAP_INIT_CLEANUP flag.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavcodec/magicyuvenc.c | 1 +
>  1 file changed, 1 insertion(+)

ok

> 
> diff --git a/libavcodec/magicyuvenc.c b/libavcodec/magicyuvenc.c
> index e9fe3bf519..0bd6b8ef6a 100644
> --- a/libavcodec/magicyuvenc.c
> +++ b/libavcodec/magicyuvenc.c
> @@ -587,4 +587,5 @@ AVCodec ff_magicyuv_encoder = {
>                            AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVA444P, AV_PIX_FMT_GRAY8,
>                            AV_PIX_FMT_NONE
>                        },
> +    .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/magicyuvenc.c b/libavcodec/magicyuvenc.c
index e9fe3bf519..0bd6b8ef6a 100644
--- a/libavcodec/magicyuvenc.c
+++ b/libavcodec/magicyuvenc.c
@@ -587,4 +587,5 @@  AVCodec ff_magicyuv_encoder = {
                           AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVA444P, AV_PIX_FMT_GRAY8,
                           AV_PIX_FMT_NONE
                       },
+    .caps_internal    = FF_CODEC_CAP_INIT_CLEANUP,
 };