aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-09-05 23:36:03 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2021-02-27 07:21:00 +0100
commit4c7718c1de83fb38d24d87ffe9e47fad639d2f3a (patch)
tree75bdd081d97977cf9f291506065dc5f107bbbcfc
parent2b8ad98791c2941a76254423b8b664852191b227 (diff)
downloadffmpeg-4c7718c1de83fb38d24d87ffe9e47fad639d2f3a.tar.gz
avformat/segment: Free SegmentListEntries in deinit, not write_trailer
This fixes leaks when the trailer is never written. Reviewed-by: Ridley Combs <rcombs@rcombs.me> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> (cherry picked from commit 848f96a2a6f1f60c8e0539a421d08ce8b4f24139)
-rw-r--r--libavformat/segment.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/libavformat/segment.c b/libavformat/segment.c
index 1c0cb5330c..fc67bf92b6 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -660,6 +660,8 @@ static int select_reference_stream(AVFormatContext *s)
static void seg_free(AVFormatContext *s)
{
SegmentContext *seg = s->priv_data;
+ SegmentListEntry *cur;
+
ff_format_io_close(s, &seg->list_pb);
if (seg->avf) {
if (seg->is_nullctx)
@@ -672,6 +674,14 @@ static void seg_free(AVFormatContext *s)
av_freep(&seg->times);
av_freep(&seg->frames);
av_freep(&seg->cur_entry.filename);
+
+ cur = seg->segment_list_entries;
+ while (cur) {
+ SegmentListEntry *next = cur->next;
+ av_freep(&cur->filename);
+ av_free(cur);
+ cur = next;
+ }
}
static int seg_init(AVFormatContext *s)
@@ -971,7 +981,6 @@ static int seg_write_trailer(struct AVFormatContext *s)
{
SegmentContext *seg = s->priv_data;
AVFormatContext *oc = seg->avf;
- SegmentListEntry *cur, *next;
int ret = 0;
if (!oc)
@@ -994,14 +1003,6 @@ fail:
av_opt_free(seg);
- cur = seg->segment_list_entries;
- while (cur) {
- next = cur->next;
- av_freep(&cur->filename);
- av_free(cur);
- cur = next;
- }
-
avformat_free_context(oc);
seg->avf = NULL;
return ret;