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

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


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

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

diff --git a/libavformat/stldec.c b/libavformat/stldec.c
index d6e0713f8c..fb67407ac5 100644
--- a/libavformat/stldec.c
+++ b/libavformat/stldec.c
@@ -97,8 +97,10 @@ static int stl_read_header(AVFormatContext *s)
         if (pts_start != AV_NOPTS_VALUE) {
             AVPacket *sub;
             sub = ff_subtitles_queue_insert(&stl->q, p, strlen(p), 0);
-            if (!sub)
+            if (!sub) {
+                ff_subtitles_queue_clean(&stl->q);
                 return AVERROR(ENOMEM);
+            }
             sub->pos = pos;
             sub->pts = pts_start;
             sub->duration = duration;
-- 
2.20.1



More information about the ffmpeg-devel mailing list