[FFmpeg-cvslog] avformat/mpsubdec: Fix memleak upon read header failure

Andreas Rheinhardt git at videolan.org
Fri Jul 3 20:30:14 EEST 2020


ffmpeg | branch: release/3.2 | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Sun Jun 14 03:20:09 2020 +0200| [1e0ab3a93b2c4f238084acc08cb8dd88abc1bf3a] | committer: Andreas Rheinhardt

avformat/mpsubdec: Fix memleak upon read header failure

The already parsed subtitles (contained in an FFDemuxSubtitlesQueue)
would leak if an error happened upon creating an AVStream.

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

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

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

diff --git a/libavformat/mpsubdec.c b/libavformat/mpsubdec.c
index fc1731f26e..4e6e2cb09c 100644
--- a/libavformat/mpsubdec.c
+++ b/libavformat/mpsubdec.c
@@ -97,8 +97,10 @@ static int mpsub_read_header(AVFormatContext *s)
     }
 
     st = avformat_new_stream(s, NULL);
-    if (!st)
-        return AVERROR(ENOMEM);
+    if (!st) {
+        res = AVERROR(ENOMEM);
+        goto end;
+    }
     avpriv_set_pts_info(st, 64, pts_info.den, pts_info.num);
     st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
     st->codecpar->codec_id   = AV_CODEC_ID_TEXT;



More information about the ffmpeg-cvslog mailing list