mirror of
https://gitee.com/openharmony/third_party_ffmpeg
synced 2024-11-27 13:10:37 +00:00
smacker: Free memory properly if the init function fails
Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
parent
0679cec6e8
commit
f3d57dc691
@ -532,6 +532,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) {
|
||||
|
Loading…
Reference in New Issue
Block a user