]> git.sesse.net Git - ffmpeg/commitdiff
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 dae13cae53a1e23438db9b68fc84c70f65e86339..03aed7102444fae5113c377113d27b72e4071a24 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;