From 9db19a3b06392854f28ecd187cd0f6cd660d1f53 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Thu, 11 Aug 2022 05:07:10 +1000 Subject: [PATCH] hlsdemux2: Don't leak the datetime in time map structs Add a function to clean up GstHLSTimeMap structs and free the ref on the optional associated GDateTime Part-of: --- .../ext/adaptivedemux2/hls/gsthlsdemux.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux.c b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux.c index 7dacfe1b2f..da5c8bb3b7 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux.c +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux.c @@ -1931,6 +1931,14 @@ gst_hls_time_map_new (void) return map; } +static void +gst_hls_time_map_free (GstHLSTimeMap * map) +{ + if (map->pdt) + g_date_time_unref (map->pdt); + g_free (map); +} + static void gst_hls_demux_add_time_mapping (GstHLSDemux * demux, gint64 dsn, GstClockTimeDiff stream_time, GDateTime * pdt) @@ -2018,7 +2026,7 @@ gst_hls_prune_time_mappings (GstHLSDemux * hlsdemux) } } - g_list_free_full (hlsdemux->mappings, g_free); + g_list_free_full (hlsdemux->mappings, (GDestroyNotify) gst_hls_time_map_free); hlsdemux->mappings = active; } @@ -2556,7 +2564,7 @@ gst_hls_demux_reset (GstAdaptiveDemux * ademux) demux->pending_variant = NULL; } - g_list_free_full (demux->mappings, g_free); + g_list_free_full (demux->mappings, (GDestroyNotify) gst_hls_time_map_free); demux->mappings = NULL; gst_hls_demux_clear_all_pending_data (demux);