Browse Source

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>
tags/n3.0
Michael Niedermayer 10 years ago
parent
commit
47c5a3058e
1 changed files with 6 additions and 4 deletions
  1. +6
    -4
      libavcodec/pngdec.c

+ 6
- 4
libavcodec/pngdec.c View File

@@ -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);


Loading…
Cancel
Save