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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2873>
This commit is contained in:
Jan Schmidt 2022-08-11 05:36:15 +10:00 committed by GStreamer Marge Bot
parent 0ff317f107
commit a6eb725413

View file

@ -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);