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
Unified · Split
| @@ -885,10 +885,9 @@ static inline void MPV_motion_lowres(MpegEncContext *s, · 884 unmodified lines | ||
| 885 | 885 | s->mv[dir][1][0], s->mv[dir][1][1], |
| 886 | 886 | block_s, mb_y); |
| 887 | 887 | } else { |
| 888 | − if (s->picture_structure != s->field_select[dir][0] + 1 && | |
| 889 | − s->pict_type != AV_PICTURE_TYPE_B && !s->first_field) { | |
| 888 | + if ( s->picture_structure != s->field_select[dir][0] + 1 && s->pict_type != AV_PICTURE_TYPE_B && !s->first_field | |
| 889 | + || !ref_picture[0]) { | |
| 890 | 890 | ref_picture = s->current_picture_ptr->f->data; |
| 891 | − | |
| 892 | 891 | } |
| 893 | 892 | mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, |
| 894 | 893 | 0, 0, s->field_select[dir][0], |
| @@ -901,8 +900,9 @@ static inline void MPV_motion_lowres(MpegEncContext *s, · 6 unmodified lines | ||
| 901 | 900 | for (int i = 0; i < 2; i++) { |
| 902 | 901 | uint8_t *const *ref2picture; |
| 903 | 902 | |
| 904 | − if (s->picture_structure == s->field_select[dir][i] + 1 || | |
| 905 | − s->pict_type == AV_PICTURE_TYPE_B || s->first_field) { | |
| 903 | + if ((s->picture_structure == s->field_select[dir][i] + 1 || | |
| 904 | + s->pict_type == AV_PICTURE_TYPE_B || s->first_field) && | |
| 905 | + ref_picture[0]) { | |
| 906 | 906 | ref2picture = ref_picture; |
| 907 | 907 | } else { |
| 908 | 908 | ref2picture = s->current_picture_ptr->f->data; |
| @@ -933,6 +933,9 @@ static inline void MPV_motion_lowres(MpegEncContext *s, · 24 unmodified lines | ||
| 933 | 933 | pix_op = s->h264chroma.avg_h264_chroma_pixels_tab; |
| 934 | 934 | } |
| 935 | 935 | } else { |
| 936 | + if (!ref_picture[0]) { | |
| 937 | + ref_picture = s->current_picture_ptr->f->data; | |
| 938 | + } | |
| 936 | 939 | for (int i = 0; i < 2; i++) { |
| 937 | 940 | mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, |
| 938 | 941 | 0, 0, s->picture_structure != i + 1, |