[FFmpeg-cvslog] avformat/segment: Fix leak of string on error

Andreas Rheinhardt git at videolan.org
Thu Sep 10 14:44:42 EEST 2020


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Sat Sep  5 21:22:21 2020 +0200| [3152a2a218578ad3c024dcd7d4ced06b396d30e1] | committer: Andreas Rheinhardt

avformat/segment: Fix leak of string on error

A string containing the segment's filename that the segment muxer
allocates got only freed in its write_trailer function. This implies
that it leaks if write_trailer is never called, e.g. if initializing
the child muxer fails. This commit fixes this by freeing the string
in the deinit function instead.

Reviewed-by: Ridley Combs <rcombs at rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>

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

 libavformat/segment.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/segment.c b/libavformat/segment.c
index 858ccf8697..5cc9eb812f 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -664,6 +664,7 @@ static void seg_free(AVFormatContext *s)
     seg->avf = NULL;
     av_freep(&seg->times);
     av_freep(&seg->frames);
+    av_freep(&seg->cur_entry.filename);
 }
 
 static int seg_init(AVFormatContext *s)
@@ -983,7 +984,6 @@ fail:
         ff_format_io_close(s, &seg->list_pb);
 
     av_opt_free(seg);
-    av_freep(&seg->cur_entry.filename);
 
     cur = seg->segment_list_entries;
     while (cur) {



More information about the ffmpeg-cvslog mailing list