[FFmpeg-cvslog] avformat/matroskadec: Fix memleaks in WebM DASH manifest demuxer

Andreas Rheinhardt git at videolan.org
Thu Jul 2 14:12:25 EEST 2020


ffmpeg | branch: release/4.0 | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Sat Jun 13 23:58:32 2020 +0200| [5084210d8ce0dd16646f1e4139b215ae2edeb257] | committer: Andreas Rheinhardt

avformat/matroskadec: Fix memleaks in WebM DASH manifest demuxer

In certain error scenarios, the underlying Matroska demuxer was not
properly closed, causing leaks.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
(cherry picked from commit 0841063ce6a2e664fb3986b0a255c57392cd9f02)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>

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

 libavformat/matroskadec.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 35344fbadc..1c996f93e4 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -3961,14 +3961,17 @@ static int webm_dash_manifest_read_header(AVFormatContext *s)
         return -1;
     }
     if (!matroska->tracks.nb_elem || !s->nb_streams) {
-        matroska_read_close(s);
         av_log(s, AV_LOG_ERROR, "No track found\n");
-        return AVERROR_INVALIDDATA;
+        ret = AVERROR_INVALIDDATA;
+        goto fail;
     }
 
     if (!matroska->is_live) {
         buf = av_asprintf("%g", matroska->duration);
-        if (!buf) return AVERROR(ENOMEM);
+        if (!buf) {
+            ret = AVERROR(ENOMEM);
+            goto fail;
+        }
         av_dict_set(&s->streams[0]->metadata, DURATION, buf, 0);
         av_free(buf);
 
@@ -3991,7 +3994,7 @@ static int webm_dash_manifest_read_header(AVFormatContext *s)
         ret = webm_dash_manifest_cues(s, init_range);
         if (ret < 0) {
             av_log(s, AV_LOG_ERROR, "Error parsing Cues\n");
-            return ret;
+            goto fail;
         }
     }
 
@@ -4001,6 +4004,9 @@ static int webm_dash_manifest_read_header(AVFormatContext *s)
                         matroska->bandwidth, 0);
     }
     return 0;
+fail:
+    matroska_read_close(s);
+    return ret;
 }
 
 static int webm_dash_manifest_read_packet(AVFormatContext *s, AVPacket *pkt)



More information about the ffmpeg-cvslog mailing list