1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-10 06:10:52 +02:00

avcodec/mpegvideo_dec: Add NULL pointer checks to MPV_motion_lowres()

This makes the null pointer checks match mpv_motion_internal()

Fixes: NULL pointer dereference
Fixes: 59671/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG1VIDEO_fuzzer-4993004566609920
Fixes: 59678/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEGVIDEO_fuzzer-4893168991338496

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer
2023-06-08 18:17:46 +02:00
parent d7d3f1af2a
commit adfe003f51

View File

@@ -885,10 +885,9 @@ static inline void MPV_motion_lowres(MpegEncContext *s,
s->mv[dir][1][0], s->mv[dir][1][1], s->mv[dir][1][0], s->mv[dir][1][1],
block_s, mb_y); block_s, mb_y);
} else { } else {
if (s->picture_structure != s->field_select[dir][0] + 1 && if ( s->picture_structure != s->field_select[dir][0] + 1 && s->pict_type != AV_PICTURE_TYPE_B && !s->first_field
s->pict_type != AV_PICTURE_TYPE_B && !s->first_field) { || !ref_picture[0]) {
ref_picture = s->current_picture_ptr->f->data; ref_picture = s->current_picture_ptr->f->data;
} }
mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
0, 0, s->field_select[dir][0], 0, 0, s->field_select[dir][0],
@@ -901,8 +900,9 @@ static inline void MPV_motion_lowres(MpegEncContext *s,
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
uint8_t *const *ref2picture; uint8_t *const *ref2picture;
if (s->picture_structure == s->field_select[dir][i] + 1 || if ((s->picture_structure == s->field_select[dir][i] + 1 ||
s->pict_type == AV_PICTURE_TYPE_B || s->first_field) { s->pict_type == AV_PICTURE_TYPE_B || s->first_field) &&
ref_picture[0]) {
ref2picture = ref_picture; ref2picture = ref_picture;
} else { } else {
ref2picture = s->current_picture_ptr->f->data; ref2picture = s->current_picture_ptr->f->data;
@@ -933,6 +933,9 @@ static inline void MPV_motion_lowres(MpegEncContext *s,
pix_op = s->h264chroma.avg_h264_chroma_pixels_tab; pix_op = s->h264chroma.avg_h264_chroma_pixels_tab;
} }
} else { } else {
if (!ref_picture[0]) {
ref_picture = s->current_picture_ptr->f->data;
}
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
0, 0, s->picture_structure != i + 1, 0, 0, s->picture_structure != i + 1,