hlsdemux2: Don't leak the datetime in time map structs
authorJan Schmidt <jan@centricular.com>
Wed, 10 Aug 2022 19:07:10 +0000 (05:07 +1000)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 12 Aug 2022 13:52:59 +0000 (13:52 +0000)
Add a function to clean up GstHLSTimeMap structs
and free the ref on the optional associated GDateTime

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2873>

subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux.c

index 7dacfe1..da5c8bb 100644 (file)
@@ -1932,6 +1932,14 @@ gst_hls_time_map_new (void)
 }
 
 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);