diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2015-10-11 13:09:56 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2015-10-11 13:09:56 +0200 |
commit | 47c5a3058eeae2043bd0dc2704b024cac8adcb3b (patch) | |
tree | 85393983536a1273327c97f993c14bceaefeaa22 | |
parent | 14573b9b7cb0683310a91d5bd2e73bd575af3f49 (diff) | |
download | ffmpeg-47c5a3058eeae2043bd0dc2704b024cac8adcb3b.tar.gz |
avcodec/pngdec: Alloc buffer after blend_op check in handle_p_frame_apng()
Avoids memleak on error
Fixes CID1322342
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavcodec/pngdec.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 2ab456d6e0..a998b1d4a3 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -969,10 +969,7 @@ static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s, AVFrame *p) { size_t x, y; - uint8_t *buffer = av_malloc(s->image_linesize * s->height); - - if (!buffer) - return AVERROR(ENOMEM); + uint8_t *buffer; if (s->blend_op == APNG_BLEND_OP_OVER && avctx->pix_fmt != AV_PIX_FMT_RGBA && @@ -983,6 +980,11 @@ static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s, return AVERROR_PATCHWELCOME; } + buffer = av_malloc(s->image_linesize * s->height); + if (!buffer) + return AVERROR(ENOMEM); + + // Do the disposal operation specified by the last frame on the frame if (s->last_dispose_op != APNG_DISPOSE_OP_PREVIOUS) { ff_thread_await_progress(&s->last_picture, INT_MAX, 0); |