avformat/mlvdec: fail reading a packet with 0 streams
authorMichael Niedermayer <michael@niedermayer.cc>
Sun, 31 May 2020 12:30:43 +0000 (14:30 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 7 Jun 2020 20:01:12 +0000 (22:01 +0200)
Fixes: NULL pointer dereference
Fixes: 22604/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5667739074297856.fuzz

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/mlvdec.c

index dae13ca..03aed71 100644 (file)
@@ -393,10 +393,14 @@ static int read_packet(AVFormatContext *avctx, AVPacket *pkt)
 {
     MlvContext *mlv = avctx->priv_data;
     AVIOContext *pb;
-    AVStream *st = avctx->streams[mlv->stream_index];
+    AVStream *st;
     int index, ret;
     unsigned int size, space;
 
+    if (!avctx->nb_streams)
+        return AVERROR_EOF;
+
+    st = avctx->streams[mlv->stream_index];
     if (mlv->pts >= st->duration)
         return AVERROR_EOF;