]> git.sesse.net Git - ffmpeg/commitdiff
avformat/icodec: Change order of operations to avoid NULL dereference
authorMichael Niedermayer <michael@niedermayer.cc>
Fri, 16 Oct 2020 17:05:23 +0000 (19:05 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Sat, 17 Oct 2020 12:36:11 +0000 (14:36 +0200)
Fixes: SEGV on unknown address 0x000000000000
Fixes: 26379/clusterfuzz-testcase-minimized-ffmpeg_dem_ICO_fuzzer-5709011753893888
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Peter Ross
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/icodec.c

index b47fa98f8007634915b709e161a04592b33a34bf..c061f3ec421308e96169310e4ead67e29d8edf64 100644 (file)
@@ -156,12 +156,14 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
     IcoDemuxContext *ico = s->priv_data;
     IcoImage *image;
     AVIOContext *pb = s->pb;
-    AVStream *st = s->streams[0];
+    AVStream *st;
     int ret;
 
     if (ico->current_image >= ico->nb_images)
         return AVERROR_EOF;
 
+    st = s->streams[0];
+
     image = &ico->images[ico->current_image];
 
     if ((ret = avio_seek(pb, image->offset, SEEK_SET)) < 0)