avformat/4xm: Check that a video stream was created before returning packets for it

Fixes: assertion failure
Fixes: 23434/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5227750851084288.fuzz

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c517c3f474)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2020-06-14 19:51:23 +02:00
parent 26b097f06c
commit c12f7ef056
1 changed files with 3 additions and 0 deletions

View File

@ -218,6 +218,7 @@ static int fourxm_read_header(AVFormatContext *s)
fourxm->track_count = 0;
fourxm->tracks = NULL;
fourxm->fps = (AVRational){1,1};
fourxm->video_stream_index = -1;
/* skip the first 3 32-bit numbers */
avio_skip(pb, 12);
@ -323,6 +324,8 @@ static int fourxm_read_packet(AVFormatContext *s,
case cfr2_TAG:
/* allocate 8 more bytes than 'size' to account for fourcc
* and size */
if (fourxm->video_stream_index < 0)
return AVERROR_INVALIDDATA;
if (size + 8 < size || av_new_packet(pkt, size + 8))
return AVERROR(EIO);
pkt->stream_index = fourxm->video_stream_index;