From a6eb7254137639fbaaa9a0fc511b949077bfbc2c Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Thu, 11 Aug 2022 05:36:15 +1000 Subject: [PATCH] hlsdemux2: m3u8: Fix memory leaks on parsing Fix memory leaks when parsing of an m3u8 file is incomplete, with EXTINF or EXT-X-PROGRAM-DATE-TIME directives, but no segment url. Part-of: --- subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c index b0a1161..cc2fdce 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c @@ -509,6 +509,7 @@ gst_hls_media_playlist_parse (gchar * data, const gchar * uri, data = NULL; date_time = NULL; duration = 0; + g_free (title); title = NULL; discontinuity = FALSE; size = offset = -1; @@ -552,9 +553,9 @@ gst_hls_media_playlist_parse (gchar * data, const gchar * uri, if (last_init_file) file->init_file = gst_m3u8_init_file_ref (last_init_file); - date_time = NULL; + date_time = NULL; /* Ownership was passed to the segment */ duration = 0; - title = NULL; + title = NULL; /* Ownership was passed to the segment */ discontinuity = FALSE; size = offset = -1; g_ptr_array_add (self->segments, file); @@ -737,8 +738,12 @@ gst_hls_media_playlist_parse (gchar * data, const gchar * uri, data = g_utf8_next_char (end); /* skip \n */ } + /* Clean up date that wasn't freed / handed to a segment */ g_free (current_key); current_key = NULL; + if (date_time) + g_date_time_unref (date_time); + g_free (title); g_free (input_data); -- 2.7.4