From 90d939ea363d396aeef3159148b6ea09ae037a4c Mon Sep 17 00:00:00 2001 From: Sam Gigliotti Date: Wed, 28 Aug 2019 17:26:00 -0700 Subject: [PATCH] webrtcbin: Fixed memory leak in gstwebrtcstats The function _get_stats_from_ice_transport returns a string which must be freed by the caller. However, _get_stats_from_dtls_transport was ignoring the return value from this function, resulting in a leak. Ran this with valgrind. Before this fix there was a leak of 40 bytes each time this was called. After there was no leak. --- ext/webrtc/gstwebrtcstats.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ext/webrtc/gstwebrtcstats.c b/ext/webrtc/gstwebrtcstats.c index bf3830413f..faa83b7fde 100644 --- a/ext/webrtc/gstwebrtcstats.c +++ b/ext/webrtc/gstwebrtcstats.c @@ -353,6 +353,7 @@ _get_stats_from_dtls_transport (GstWebRTCBin * webrtc, GstStructure *stats; gchar *id; double ts; + gchar *ice_id; gst_structure_get_double (s, "timestamp", &ts); @@ -395,7 +396,8 @@ _get_stats_from_dtls_transport (GstWebRTCBin * webrtc, gst_structure_set (s, id, GST_TYPE_STRUCTURE, stats, NULL); gst_structure_free (stats); - _get_stats_from_ice_transport (webrtc, transport->transport, s); + ice_id = _get_stats_from_ice_transport (webrtc, transport->transport, s); + g_free (ice_id); return id; }