diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2016-01-17 18:01:33 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2016-01-17 20:35:36 +0100 |
commit | 033b49e02d57ffa29e208f153102ae2c0abae912 (patch) | |
tree | de21fd751640c2335f9179d573262ea5321e3dc1 | |
parent | 1f12a889da2abb32fdf2413f995db51dca430eba (diff) | |
download | ffmpeg-033b49e02d57ffa29e208f153102ae2c0abae912.tar.gz |
avcodec/libaacplus: Cleanup in case of init failure
Fixes: memleak
Fixes: 6b343214a0c12d94c1ea0ae9c3102dba/signal_sigsegv_262857d_8792_71ba605ad9ca9068b8218a6ce3628c25.mov
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavcodec/libaacplus.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/libavcodec/libaacplus.c b/libavcodec/libaacplus.c index fe380871b1..5d27e71804 100644 --- a/libavcodec/libaacplus.c +++ b/libavcodec/libaacplus.c @@ -35,6 +35,8 @@ typedef struct aacPlusAudioContext { unsigned long samples_input; } aacPlusAudioContext; +static int aacPlus_encode_close(AVCodecContext *avctx); + static av_cold int aacPlus_encode_init(AVCodecContext *avctx) { aacPlusAudioContext *s = avctx->priv_data; @@ -67,6 +69,7 @@ static av_cold int aacPlus_encode_init(AVCodecContext *avctx) aacplus_cfg->inputFormat = avctx->sample_fmt == AV_SAMPLE_FMT_FLT ? AACPLUS_INPUT_FLOAT : AACPLUS_INPUT_16BIT; if (!aacplusEncSetConfiguration(s->aacplus_handle, aacplus_cfg)) { av_log(avctx, AV_LOG_ERROR, "libaacplus doesn't support this output format!\n"); + aacPlus_encode_close(avctx); return AVERROR(EINVAL); } @@ -84,6 +87,7 @@ static av_cold int aacPlus_encode_init(AVCodecContext *avctx) avctx->extradata = av_malloc(decoder_specific_info_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) { free(buffer); + aacPlus_encode_close(avctx); return AVERROR(ENOMEM); } avctx->extradata_size = decoder_specific_info_size; @@ -117,6 +121,7 @@ static av_cold int aacPlus_encode_close(AVCodecContext *avctx) av_freep(&avctx->extradata); aacplusEncClose(s->aacplus_handle); + s->aacplus_handle = NULL; return 0; } |