diff options
author | Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> | 2016-12-02 22:52:44 +0100 |
---|---|---|
committer | Vittorio Giovara <vittorio.giovara@gmail.com> | 2016-12-08 15:53:58 -0500 |
commit | dc2ad094931de2b28c63eaa5614756ed74e2579e (patch) | |
tree | c8ec078a4cad69afb804486260e401c9ab9d3be1 | |
parent | 8c3a643808fc89c8003478ea952187cd9fe5d27a (diff) | |
download | ffmpeg-dc2ad094931de2b28c63eaa5614756ed74e2579e.tar.gz |
libschroedingerdec: fix leaking of framewithpts
Also preserve the return value from ff_get_buffer().
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
-rw-r--r-- | libavcodec/libschroedingerdec.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/libavcodec/libschroedingerdec.c b/libavcodec/libschroedingerdec.c index 56b2f6d778..69eed01ce0 100644 --- a/libavcodec/libschroedingerdec.c +++ b/libavcodec/libschroedingerdec.c @@ -218,6 +218,7 @@ static int libschroedinger_decode_frame(AVCodecContext *avctx, int outer = 1; SchroParseUnitContext parse_ctx; LibSchroFrameContext *framewithpts = NULL; + int ret; *got_frame = 0; @@ -308,9 +309,9 @@ static int libschroedinger_decode_frame(AVCodecContext *avctx, framewithpts = ff_schro_queue_pop(&p_schro_params->dec_frame_queue); if (framewithpts && framewithpts->frame && framewithpts->frame->components[0].stride) { - if (ff_get_buffer(avctx, avframe, 0) < 0) { + if ((ret = ff_get_buffer(avctx, avframe, 0)) < 0) { av_log(avctx, AV_LOG_ERROR, "Unable to allocate buffer\n"); - return AVERROR(ENOMEM); + goto end; } memcpy(avframe->data[0], @@ -337,15 +338,17 @@ FF_ENABLE_DEPRECATION_WARNINGS avframe->linesize[2] = framewithpts->frame->components[2].stride; *got_frame = 1; - - /* Now free the frame resources. */ - libschroedinger_decode_frame_free(framewithpts->frame); - av_free(framewithpts); } else { data = NULL; *got_frame = 0; } - return buf_size; + ret = buf_size; +end: + /* Now free the frame resources. */ + if (framewithpts && framewithpts->frame) + libschroedinger_decode_frame_free(framewithpts->frame); + av_freep(&framewithpts); + return ret; } |