diff mbox series

[FFmpeg-devel,05/10] avformat/segment: Fix leak of string on error

Message ID 20200907024952.11697-5-andreas.rheinhardt@gmail.com
State Accepted
Commit 3152a2a218578ad3c024dcd7d4ced06b396d30e1
Headers show
Series [FFmpeg-devel,01/10] avformat/segment: Don't overwrite AVCodecParameters after init
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 7, 2020, 2:49 a.m. UTC
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.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/segment.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavformat/segment.c b/libavformat/segment.c
index e30e47b62e..b8eb0289c4 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -665,6 +665,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)
@@ -993,7 +994,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) {