diff options
author | Martin Storsjö <martin@martin.st> | 2013-09-11 15:55:18 +0300 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2013-09-11 20:20:50 +0300 |
commit | f3d57dc69145f1b7acb4870da9ce60378190a1fd (patch) | |
tree | a17974d78614afb952652c5c2c0c99adb4918ec8 /libavcodec | |
parent | 0679cec6e8802643bbe6d5f68ca1110a7d3171da (diff) | |
download | ffmpeg-f3d57dc69145f1b7acb4870da9ce60378190a1fd.tar.gz |
smacker: Free memory properly if the init function fails
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/smacker.c | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c index 9819fa58cc..c8850d3368 100644 --- a/libavcodec/smacker.c +++ b/libavcodec/smacker.c @@ -534,6 +534,26 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, /* * + * Uninit smacker decoder + * + */ +static av_cold int decode_end(AVCodecContext *avctx) +{ + SmackVContext * const smk = avctx->priv_data; + + av_freep(&smk->mmap_tbl); + av_freep(&smk->mclr_tbl); + av_freep(&smk->full_tbl); + av_freep(&smk->type_tbl); + + av_frame_unref(&smk->pic); + + return 0; +} + + +/* + * * Init smacker decoder * */ @@ -552,34 +572,16 @@ static av_cold int decode_init(AVCodecContext *avctx) return -1; } - if (decode_header_trees(c)) + if (decode_header_trees(c)) { + decode_end(avctx); return -1; + } return 0; } -/* - * - * Uninit smacker decoder - * - */ -static av_cold int decode_end(AVCodecContext *avctx) -{ - SmackVContext * const smk = avctx->priv_data; - - av_freep(&smk->mmap_tbl); - av_freep(&smk->mclr_tbl); - av_freep(&smk->full_tbl); - av_freep(&smk->type_tbl); - - av_frame_unref(&smk->pic); - - return 0; -} - - static av_cold int smka_decode_init(AVCodecContext *avctx) { if (avctx->channels < 1 || avctx->channels > 2) { |