diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2020-10-16 19:05:23 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2021-09-11 21:23:48 +0200 |
commit | 99f6a8ed8a5745e4cb20c8e1a34757600efc49b6 (patch) | |
tree | 087aed9d4d612c807af2ad808ff1f4a325fa90a2 | |
parent | feab2fb911c3379e0638089a31c8ab9bfe3b9c0e (diff) | |
download | ffmpeg-99f6a8ed8a5745e4cb20c8e1a34757600efc49b6.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.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libavformat/icodec.c b/libavformat/icodec.c index 00c03d409c..59e5416116 100644 --- a/libavformat/icodec.c +++ b/libavformat/icodec.c @@ -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) |