diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2019-06-08 10:48:41 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2019-06-27 17:50:47 +0200 |
commit | 45d3ba9e5f57761a56f08f743f8ba9a137fca623 (patch) | |
tree | e807a3da676a53da45214c68a4de8f5c54a186cc | |
parent | 0789b6295bbf343ef07bb6629ff19aaf1de49ed7 (diff) | |
download | ffmpeg-45d3ba9e5f57761a56f08f743f8ba9a137fca623.tar.gz |
avformat/icodec: Free ico->images on error paths
Fixes: 15116/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5715173567889408
Fixes: memleak
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 54918b51161610a364de697b80acb9583eecf41b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavformat/icodec.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libavformat/icodec.c b/libavformat/icodec.c index f33fa1195b..00c03d409c 100644 --- a/libavformat/icodec.c +++ b/libavformat/icodec.c @@ -96,8 +96,10 @@ static int read_header(AVFormatContext *s) break; st = avformat_new_stream(s, NULL); - if (!st) + if (!st) { + av_freep(&ico->images); return AVERROR(ENOMEM); + } st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; st->codecpar->width = avio_r8(pb); @@ -111,6 +113,7 @@ static int read_header(AVFormatContext *s) ico->images[i].size = avio_rl32(pb); if (ico->images[i].size <= 0) { av_log(s, AV_LOG_ERROR, "Invalid image size %d\n", ico->images[i].size); + av_freep(&ico->images); return AVERROR_INVALIDDATA; } ico->images[i].offset = avio_rl32(pb); @@ -126,8 +129,10 @@ static int read_header(AVFormatContext *s) st->codecpar->height = 0; break; case 40: - if (ico->images[i].size < 40) + if (ico->images[i].size < 40) { + av_freep(&ico->images); return AVERROR_INVALIDDATA; + } st->codecpar->codec_id = AV_CODEC_ID_BMP; tmp = avio_rl32(pb); if (tmp) @@ -138,6 +143,7 @@ static int read_header(AVFormatContext *s) break; default: avpriv_request_sample(s, "codec %d", codec); + av_freep(&ico->images); return AVERROR_INVALIDDATA; } } |