diff mbox series

[FFmpeg-devel,20/30] avcodec/mlpenc: Fix memleak upon init failure

Message ID 20200915074000.102622-20-andreas.rheinhardt@gmail.com
State Accepted
Commit b78031cf1670c176e97f62ad6a4865d3a44c1507
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/mlpenc.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Paul B Mahol Sept. 15, 2020, 4:51 p.m. UTC | #1
On Tue, Sep 15, 2020 at 09:39:50AM +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/mlpenc.c | 2 ++
>  1 file changed, 2 insertions(+)
> 

lgtm

> diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c
> index 52ea06ed91..f6159d39c8 100644
> --- a/libavcodec/mlpenc.c
> +++ b/libavcodec/mlpenc.c
> @@ -2391,6 +2391,7 @@ AVCodec ff_mlp_encoder = {
>      .sample_fmts            = (const enum AVSampleFormat[]) {AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE},
>      .supported_samplerates  = (const int[]) {44100, 48000, 88200, 96000, 176400, 192000, 0},
>      .channel_layouts        = ff_mlp_channel_layouts,
> +    .caps_internal          = FF_CODEC_CAP_INIT_CLEANUP,
>  };
>  #endif
>  #if CONFIG_TRUEHD_ENCODER
> @@ -2407,5 +2408,6 @@ AVCodec ff_truehd_encoder = {
>      .sample_fmts            = (const enum AVSampleFormat[]) {AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE},
>      .supported_samplerates  = (const int[]) {44100, 48000, 88200, 96000, 176400, 192000, 0},
>      .channel_layouts        = (const uint64_t[]) {AV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_5POINT0_BACK, AV_CH_LAYOUT_5POINT1_BACK, 0},
> +    .caps_internal          = FF_CODEC_CAP_INIT_CLEANUP,
>  };
>  #endif
> -- 
> 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/mlpenc.c b/libavcodec/mlpenc.c
index 52ea06ed91..f6159d39c8 100644
--- a/libavcodec/mlpenc.c
+++ b/libavcodec/mlpenc.c
@@ -2391,6 +2391,7 @@  AVCodec ff_mlp_encoder = {
     .sample_fmts            = (const enum AVSampleFormat[]) {AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE},
     .supported_samplerates  = (const int[]) {44100, 48000, 88200, 96000, 176400, 192000, 0},
     .channel_layouts        = ff_mlp_channel_layouts,
+    .caps_internal          = FF_CODEC_CAP_INIT_CLEANUP,
 };
 #endif
 #if CONFIG_TRUEHD_ENCODER
@@ -2407,5 +2408,6 @@  AVCodec ff_truehd_encoder = {
     .sample_fmts            = (const enum AVSampleFormat[]) {AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE},
     .supported_samplerates  = (const int[]) {44100, 48000, 88200, 96000, 176400, 192000, 0},
     .channel_layouts        = (const uint64_t[]) {AV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_5POINT0_BACK, AV_CH_LAYOUT_5POINT1_BACK, 0},
+    .caps_internal          = FF_CODEC_CAP_INIT_CLEANUP,
 };
 #endif