aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-09-12 12:57:58 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-09-12 12:57:58 +0200
commitaf539319af3a2c173e275fb927c7069e6b167114 (patch)
tree5ca40632b1bb05f9ca59ac7eca08eec12946ae80
parentf8932d990228c53ee498b17eadf9dae4755c87ab (diff)
parentf3d57dc69145f1b7acb4870da9ce60378190a1fd (diff)
downloadffmpeg-af539319af3a2c173e275fb927c7069e6b167114.tar.gz
Merge commit 'f3d57dc69145f1b7acb4870da9ce60378190a1fd'
* commit 'f3d57dc69145f1b7acb4870da9ce60378190a1fd': smacker: Free memory properly if the init function fails Conflicts: libavcodec/smacker.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/smacker.c45
1 files changed, 23 insertions, 22 deletions
diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c
index 6fe2cc97f6..899ba23e90 100644
--- a/libavcodec/smacker.c
+++ b/libavcodec/smacker.c
@@ -552,6 +552,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_free(&smk->pic);
+
+ return 0;
+}
+
+
+/*
+ *
* Init smacker decoder
*
*/
@@ -571,8 +591,10 @@ static av_cold int decode_init(AVCodecContext *avctx)
}
ret = decode_header_trees(c);
- if (ret < 0)
+ if (ret < 0) {
+ decode_end(avctx);
return ret;
+ }
c->pic = av_frame_alloc();
if (!c->pic)
@@ -582,27 +604,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
}
-
-/*
- *
- * 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_free(&smk->pic);
-
- return 0;
-}
-
-
static av_cold int smka_decode_init(AVCodecContext *avctx)
{
if (avctx->channels < 1 || avctx->channels > 2) {