[FFmpeg-cvslog] avformat/vividas: Fix memleak of AVIOContext in track_header()

Michael Niedermayer git at videolan.org
Mon Aug 5 20:50:26 EEST 2019


ffmpeg | branch: release/4.2 | Michael Niedermayer <michael at niedermayer.cc> | Sun Aug  4 12:13:21 2019 +0200| [8d171808847ee9fd59b31d976205141a92890599] | committer: Michael Niedermayer

avformat/vividas: Fix memleak of AVIOContext in track_header()

Fixes: memleak
Fixes: 16127/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5649290914955264

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit 76133d7c8bfe19833e1973849eabe6a78913e4aa)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8d171808847ee9fd59b31d976205141a92890599
---

 libavformat/vividas.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavformat/vividas.c b/libavformat/vividas.c
index c3d3cf548c..e70c9164a1 100644
--- a/libavformat/vividas.c
+++ b/libavformat/vividas.c
@@ -375,15 +375,19 @@ static int track_header(VividasDemuxContext *viv, AVFormatContext *s,  uint8_t *
             num_data = avio_r8(pb);
             for (j = 0; j < num_data; j++) {
                 uint64_t len = ffio_read_varlen(pb);
-                if (len > INT_MAX/2 - xd_size)
+                if (len > INT_MAX/2 - xd_size) {
+                    av_free(pb);
                     return AVERROR_INVALIDDATA;
+                }
                 data_len[j] = len;
                 xd_size += len;
             }
 
             st->codecpar->extradata_size = 64 + xd_size + xd_size / 255;
-            if (ff_alloc_extradata(st->codecpar, st->codecpar->extradata_size))
+            if (ff_alloc_extradata(st->codecpar, st->codecpar->extradata_size)) {
+                av_free(pb);
                 return AVERROR(ENOMEM);
+            }
 
             p = st->codecpar->extradata;
             p[0] = 2;



More information about the ffmpeg-cvslog mailing list