aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-09-13 01:10:40 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2021-02-27 07:20:57 +0100
commit2e05113b927f09c3fa872028b6a588ac040c39d6 (patch)
treeaa3952b6ea8a90998a0458f11f5868b9b56365bd
parent0dd79193a773d867b624095d555ebf01c2529ebe (diff)
downloadffmpeg-2e05113b927f09c3fa872028b6a588ac040c39d6.tar.gz
avcodec/sonic: Fix leaks upon allocation errors
The Sonic decoder and encoders allocate several buffers in their init function and return immediately if one of these allocations fails; this will lead to leaks if there was an earlier successfull allocation. Fix this by setting the FF_CODEC_CAP_INIT_CLEANUP flag. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> (cherry picked from commit 7d91f9271ee336da93b6871bf3306348ac1595a7)
-rw-r--r--libavcodec/sonic.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c
index c635005bec..1bd604a2fa 100644
--- a/libavcodec/sonic.c
+++ b/libavcodec/sonic.c
@@ -1096,6 +1096,7 @@ AVCodec ff_sonic_decoder = {
.close = sonic_decode_close,
.decode = sonic_decode_frame,
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_EXPERIMENTAL,
+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
};
#endif /* CONFIG_SONIC_DECODER */
@@ -1110,6 +1111,7 @@ AVCodec ff_sonic_encoder = {
.encode2 = sonic_encode_frame,
.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE },
.capabilities = AV_CODEC_CAP_EXPERIMENTAL,
+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
.close = sonic_encode_close,
};
#endif
@@ -1125,6 +1127,7 @@ AVCodec ff_sonic_ls_encoder = {
.encode2 = sonic_encode_frame,
.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE },
.capabilities = AV_CODEC_CAP_EXPERIMENTAL,
+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
.close = sonic_encode_close,
};
#endif