]> git.sesse.net Git - ffmpeg/commitdiff
avformat/segment: Fix leak of string on error
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Sat, 5 Sep 2020 19:22:21 +0000 (21:22 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Thu, 10 Sep 2020 11:44:12 +0000 (13:44 +0200)
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@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavformat/segment.c

index 858ccf86975c2cdfb3708824f8c133480c5c8ee1..5cc9eb812f1d815a014bec100c72241482ed2813 100644 (file)
@@ -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) {