summaryrefslogtreecommitdiff
path: root/libavcodec/mpegpicture.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2021-03-18 19:19:54 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2021-04-01 11:38:44 +0200
commitd416d7f0618a3f183b9b5accd6205b9e3db9986f (patch)
tree0d8bfda9582da4e69a71c8287fcd1580c21f01ba /libavcodec/mpegpicture.c
parent807b703a48a7859098709916a0e438e3eec3bd7c (diff)
downloadffmpeg-d416d7f0618a3f183b9b5accd6205b9e3db9986f.tar.gz
avcodec/mpegpicture: Keep ff_mpeg_framesize_alloc() failure state consistent
Fixes: null pointer dereference Fixes: ff_put_pixels16_sse2.mp4 Found-by: Rafael Dutra <rafael.dutra@cispa.de> Regression-since: 4b2863ff01b1fe93d9a518523c9098d17a9d8c6f Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 76cea1d2ce3f23e8131c8664086a1daf873ed694) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/mpegpicture.c')
-rw-r--r--libavcodec/mpegpicture.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c
index e3f648895d..0652b7c879 100644
--- a/libavcodec/mpegpicture.c
+++ b/libavcodec/mpegpicture.c
@@ -79,8 +79,11 @@ int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me,
// linesize * interlaced * MBsize
// we also use this buffer for encoding in encode_mb_internal() needig an additional 32 lines
if (!FF_ALLOCZ_TYPED_ARRAY(sc->edge_emu_buffer, alloc_size * EMU_EDGE_HEIGHT) ||
- !FF_ALLOCZ_TYPED_ARRAY(me->scratchpad, alloc_size * 4 * 16 * 2))
+ !FF_ALLOCZ_TYPED_ARRAY(me->scratchpad, alloc_size * 4 * 16 * 2)) {
+ av_freep(&sc->edge_emu_buffer);
return AVERROR(ENOMEM);
+ }
+
me->temp = me->scratchpad;
sc->rd_scratchpad = me->scratchpad;
sc->b_scratchpad = me->scratchpad;