]> git.sesse.net Git - ffmpeg/commitdiff
avformat/pjsdec: Fix memleak upon read header failure
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Sun, 14 Jun 2020 01:21:03 +0000 (03:21 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Mon, 15 Jun 2020 14:54:05 +0000 (16:54 +0200)
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@gmail.com>
libavformat/pjsdec.c

index 8a5cc04f8411e4370b64de842497c92deaeab8b5..e30c23d830487b9671fac77b9bd2519662912127 100644 (file)
@@ -94,8 +94,10 @@ static int pjs_read_header(AVFormatContext *s)
 
             p[strcspn(p, "\"")] = 0;
             sub = ff_subtitles_queue_insert(&pjs->q, p, strlen(p), 0);
-            if (!sub)
+            if (!sub) {
+                ff_subtitles_queue_clean(&pjs->q);
                 return AVERROR(ENOMEM);
+            }
             sub->pos = pos;
             sub->pts = pts_start;
             sub->duration = duration;