]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/ac3enc_float, eac3enc: Fix leaks on init error
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Mon, 14 Sep 2020 01:35:52 +0000 (03:35 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Fri, 18 Sep 2020 00:52:15 +0000 (02:52 +0200)
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
libavcodec/eac3enc.c

index 1f3111af0e5cf924720924848becd922728d4782..99863a9722ab83a109622b9824ae85977903328a 100644 (file)
@@ -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,
 };
index 6a90571e5647b32d1869d619cb53927f057069ca..8e1032f268658a22ec9d8fb6b917f350bdfa147a 100644 (file)
@@ -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,
 };