Skip to content

Commit

Permalink
avcodec/mpegpicture: Keep ff_mpeg_framesize_alloc() failure state con…
Browse files Browse the repository at this point in the history
…sistent

Fixes: null pointer dereference
Fixes: ff_put_pixels16_sse2.mp4

Found-by: Rafael Dutra <[email protected]>
Regression-since: 4b2863f
Signed-off-by: Michael Niedermayer <[email protected]>
  • Loading branch information
michaelni committed Mar 31, 2021
1 parent 6cc65d3 commit 76cea1d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libavcodec/mpegpicture.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 76cea1d

Please sign in to comment.