diff mbox series

[FFmpeg-devel,13/26] avformat/mpsubdec: Fix memleak upon read header failure

Message ID 20200614223656.21338-13-andreas.rheinhardt@gmail.com
State Accepted
Commit a5ed8aeea4f4199e89520c3fdbd9d07ae7fc3c3f
Headers show
Series [FFmpeg-devel,01/26] avformat/matroskadec: Move AVBufferRef instead of copying, fix memleak
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt June 14, 2020, 10:36 p.m. UTC
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@gmail.com>
---
 libavformat/mpsubdec.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/mpsubdec.c b/libavformat/mpsubdec.c
index 82c73457ea..e7b83a1d85 100644
--- a/libavformat/mpsubdec.c
+++ b/libavformat/mpsubdec.c
@@ -154,8 +154,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;