aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2020-10-16 19:05:23 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2021-10-17 21:34:53 +0200
commitb71283c68fc7a4c867cd49b1280298bb9f87e58e (patch)
tree884010846a1dee26c953aabe5742413322b0e517
parent870d5f1846e9cc4ffafd30dd46bb5a06eaf6b19b (diff)
downloadffmpeg-b71283c68fc7a4c867cd49b1280298bb9f87e58e.tar.gz
avformat/icodec: Change order of operations to avoid NULL dereference
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> (cherry picked from commit 3300f5c133650ba25f94531d40ecc94c79b84457) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavformat/icodec.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libavformat/icodec.c b/libavformat/icodec.c
index 040e454c55..c07238ec67 100644
--- a/libavformat/icodec.c
+++ b/libavformat/icodec.c
@@ -124,12 +124,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(EIO);
+ st = s->streams[0];
+
image = &ico->images[ico->current_image];
if ((ret = avio_seek(pb, image->offset, SEEK_SET)) < 0)