diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-09-05 19:36:31 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2021-02-27 07:21:00 +0100 |
commit | 1b8c6b2666f30855d82c1d368138628c140f804a (patch) | |
tree | 32cb10198098cf5ae183e101571821022da5ab7b /libavformat/segment.c | |
parent | a00952ea198685641254aee499055ec5044e0f79 (diff) | |
download | ffmpeg-1b8c6b2666f30855d82c1d368138628c140f804a.tar.gz |
avformat/segment: Fix leak of duration/framenumber lists upon error
The code to free them is not in the segment muxer's deinit function,
but in its write_trailer function which means that these lists leak if
write_trailer isn't called after their allocation. This happens e.g. if
the given lists are invalid (e.g. consisting only of ',' (which delimit
entries)), so that parsing them fails and so does the muxer's init
function; write_trailer is then never called.
This has been fixed by moving the code to free them to the deinit
function.
Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
(cherry picked from commit 4b836c86132feb67ca10e383988884dd67bcd19a)
Diffstat (limited to 'libavformat/segment.c')
-rw-r--r-- | libavformat/segment.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libavformat/segment.c b/libavformat/segment.c index 8775812ccc..fc47042d32 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -663,6 +663,8 @@ static void seg_free(AVFormatContext *s) ff_format_io_close(seg->avf, &seg->list_pb); avformat_free_context(seg->avf); seg->avf = NULL; + av_freep(&seg->times); + av_freep(&seg->frames); } static int seg_init(AVFormatContext *s) @@ -991,8 +993,6 @@ fail: ff_format_io_close(s, &seg->list_pb); av_opt_free(seg); - av_freep(&seg->times); - av_freep(&seg->frames); av_freep(&seg->cur_entry.filename); cur = seg->segment_list_entries; |