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>
This commit is contained in:
Michael Niedermayer 2013-09-12 12:57:58 +02:00
commit af539319af
1 changed files with 23 additions and 22 deletions

View File

@ -550,6 +550,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) {