diff mbox series

[FFmpeg-devel,02/20] avcodec/wma(dec|enc): Fix memleaks upon allocation error

Message ID HE1PR0301MB21549E64007F70A101034EA08F579@HE1PR0301MB2154.eurprd03.prod.outlook.com
State Accepted
Commit fcdb012a100b245890949b2d53cb7f042380787d
Headers show
Series [FFmpeg-devel,01/20] avcodec/wma: Remove nonsense volatile
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt May 7, 2021, 6:46 a.m. UTC
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@outlook.com>
---
 libavcodec/wmadec.c | 2 ++
 libavcodec/wmaenc.c | 2 ++
 2 files changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c
index 9081f35a16..b63ce66b23 100644
--- a/libavcodec/wmadec.c
+++ b/libavcodec/wmadec.c
@@ -977,6 +977,7 @@  const 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
@@ -993,5 +994,6 @@  const 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 89273ba978..2a78325298 100644
--- a/libavcodec/wmaenc.c
+++ b/libavcodec/wmaenc.c
@@ -436,6 +436,7 @@  const 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 @@  const 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