[FFmpeg-cvslog] avcodec/wma(dec|enc): Fix memleaks upon allocation error

Andreas Rheinhardt git at videolan.org
Wed Jan 12 02:51:12 EET 2022


ffmpeg | branch: release/4.4 | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Thu May  6 16:56:19 2021 +0200| [44f830e7f0182c20b36ac44ccaa10bb23c8caaff] | committer: Andreas Rheinhardt

avcodec/wma(dec|enc): Fix memleaks upon allocation error

ff_wma_init() can fail without freeing everything it has allocated;
so add the FF_CODEC_CAP_INIT_CLEANUP to the codecs using it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
(cherry picked from commit fcdb012a100b245890949b2d53cb7f042380787d)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=44f830e7f0182c20b36ac44ccaa10bb23c8caaff
---

 libavcodec/wmadec.c | 2 ++
 libavcodec/wmaenc.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c
index 8710414936..f5408a1789 100644
--- a/libavcodec/wmadec.c
+++ b/libavcodec/wmadec.c
@@ -980,6 +980,7 @@ AVCodec ff_wmav1_decoder = {
     .capabilities   = AV_CODEC_CAP_DR1,
     .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
                                                       AV_SAMPLE_FMT_NONE },
+    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };
 #endif
 #if CONFIG_WMAV2_DECODER
@@ -996,5 +997,6 @@ AVCodec ff_wmav2_decoder = {
     .capabilities   = AV_CODEC_CAP_DR1,
     .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
                                                       AV_SAMPLE_FMT_NONE },
+    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };
 #endif
diff --git a/libavcodec/wmaenc.c b/libavcodec/wmaenc.c
index 6a7e23d016..a28a0c387b 100644
--- a/libavcodec/wmaenc.c
+++ b/libavcodec/wmaenc.c
@@ -436,6 +436,7 @@ AVCodec ff_wmav1_encoder = {
     .close          = ff_wma_end,
     .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
                                                       AV_SAMPLE_FMT_NONE },
+    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };
 #endif
 #if CONFIG_WMAV2_ENCODER
@@ -450,5 +451,6 @@ AVCodec ff_wmav2_encoder = {
     .close          = ff_wma_end,
     .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
                                                       AV_SAMPLE_FMT_NONE },
+    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };
 #endif



More information about the ffmpeg-cvslog mailing list