diff mbox series

[FFmpeg-devel,35/40] avcodec/ac3enc_float, eac3enc: Fix leaks on init error

Message ID 20200914052747.124118-19-andreas.rheinhardt@gmail.com
State Accepted
Commit f4e6aa609d7e8738c172aab2c0608e20ba3f779c
Headers show
Series [FFmpeg-devel,01/16] avcodec/snowdec: Use ff_snow_common_init() directly | 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. 14, 2020, 5:27 a.m. UTC
The AC-3 encoders (both floating- as well as fixed-point) as well as
the EAC-3 encoder share code: All use ff_ac3_encode_init() as well as
ff_ac3_encode_close(). Until ee726e777b851cdd4e28cdab36b38f0c39e35ea9
ff_ac3_encode_init() called ff_ac3_encode_close() to clean up on error.
Said commit removed this and instead set the FF_CODEC_CAP_INIT_CLEANUP
flag; but it did the latter only for the fixed-point AC-3 encoder and
not for the other two users of ff_ac3_encode_init(). This caused any
already allocated buffer to leak upon a subsequent error for the two
other encoders.

This commit fixes this by adding the FF_CODEC_CAP_INIT_CLEANUP flag
to the other two encoders using ff_ac3_encode_init().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/ac3enc_float.c | 1 +
 libavcodec/eac3enc.c      | 1 +
 2 files changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c
index 1f3111af0e..99863a9722 100644
--- a/libavcodec/ac3enc_float.c
+++ b/libavcodec/ac3enc_float.c
@@ -153,4 +153,5 @@  AVCodec ff_ac3_encoder = {
     .supported_samplerates = ff_ac3_sample_rate_tab,
     .channel_layouts = ff_ac3_channel_layouts,
     .defaults        = ac3_defaults,
+    .caps_internal   = FF_CODEC_CAP_INIT_CLEANUP,
 };
diff --git a/libavcodec/eac3enc.c b/libavcodec/eac3enc.c
index 6a90571e56..8e1032f268 100644
--- a/libavcodec/eac3enc.c
+++ b/libavcodec/eac3enc.c
@@ -266,4 +266,5 @@  AVCodec ff_eac3_encoder = {
     .supported_samplerates = ff_ac3_sample_rate_tab,
     .channel_layouts = ff_ac3_channel_layouts,
     .defaults        = ac3_defaults,
+    .caps_internal   = FF_CODEC_CAP_INIT_CLEANUP,
 };