From e7780f16153051f9b169e8bdd6f0696ca03e5f34 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 15 Sep 2020 02:35:27 +0200 Subject: [PATCH] avcodec/mlpenc: Fix memleak upon init failure 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. Reviewed-by: Paul B Mahol Signed-off-by: Andreas Rheinhardt (cherry picked from commit b78031cf1670c176e97f62ad6a4865d3a44c1507) --- libavcodec/mlpenc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c index c6a7963c22..9cfa16e6be 100644 --- a/libavcodec/mlpenc.c +++ b/libavcodec/mlpenc.c @@ -2393,6 +2393,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 @@ -2409,5 +2410,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