diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2021-03-10 20:16:32 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2021-03-19 00:10:24 +0100 |
commit | 5edcdfc318b62b8327565183e8f56b3f8dd2dd16 (patch) | |
tree | 94afc6adeab058843e0faab9fb4b259511e55099 /libavcodec/pngdec.c | |
parent | da12d600ea6d16ea1b61d0b9a2530dea0bbbb870 (diff) |
avcodec/pngdec: Fix memleak by postponing allocation
Fixes Coverity ticket #1322342.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/pngdec.c')
-rw-r--r-- | libavcodec/pngdec.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index a5a71ef161..63c22063d9 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -1080,10 +1080,6 @@ static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s, return AVERROR_PATCHWELCOME; } - buffer = av_malloc_array(s->image_linesize, s->height); - if (!buffer) - return AVERROR(ENOMEM); - ff_thread_await_progress(&s->last_picture, INT_MAX, 0); // need to reset a rectangle to background: @@ -1099,7 +1095,9 @@ static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s, } } - memcpy(buffer, s->last_picture.f->data[0], s->image_linesize * s->height); + buffer = av_memdup(s->last_picture.f->data[0], s->image_linesize * s->height); + if (!buffer) + return AVERROR(ENOMEM); // Perform blending if (s->blend_op == APNG_BLEND_OP_SOURCE) { |