[FFmpeg-devel] [PATCH 08/26] avformat/assdec: Fix memleak upon read header failure

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Mon Jun 15 01:36:38 EEST 2020


The already parsed subtitles (contained in an FFDemuxSubtitlesQueue)
would leak if an error happened upon reading a subsequent subtitle
or if creating the extradata failed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
---
 libavformat/assdec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/assdec.c b/libavformat/assdec.c
index f66b296673..8fb9e8e501 100644
--- a/libavformat/assdec.c
+++ b/libavformat/assdec.c
@@ -160,6 +160,8 @@ static int ass_read_header(AVFormatContext *s)
     ff_subtitles_queue_finalize(s, &ass->q);
 
 end:
+    if (res < 0)
+        ass_read_close(s);
     av_bprint_finalize(&header, NULL);
     av_bprint_finalize(&line,   NULL);
     av_bprint_finalize(&rline,  NULL);
-- 
2.20.1



More information about the ffmpeg-devel mailing list