From 7489addc0acdd5c1781f7729048bddc02832ded0 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Mon, 24 Aug 2020 17:01:22 +1000 Subject: [PATCH] webrtc/datachannel: free previous protocol/label fields Fixes a memory leak Part-of: --- ext/webrtc/webrtcdatachannel.c | 2 ++ gst-libs/gst/webrtc/datachannel.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/ext/webrtc/webrtcdatachannel.c b/ext/webrtc/webrtcdatachannel.c index eccb0db16a..4305707254 100644 --- a/ext/webrtc/webrtcdatachannel.c +++ b/ext/webrtc/webrtcdatachannel.c @@ -416,7 +416,9 @@ _parse_control_packet (WebRTCDataChannel * channel, guint8 * data, memcpy (proto, src, proto_len); proto[proto_len] = '\0'; + g_free (channel->parent.label); channel->parent.label = label; + g_free (channel->parent.protocol); channel->parent.protocol = proto; channel->parent.priority = priority_uint_to_type (priority); channel->parent.ordered = !(reliability & 0x80); diff --git a/gst-libs/gst/webrtc/datachannel.c b/gst-libs/gst/webrtc/datachannel.c index 358eb12be4..ee0be60304 100644 --- a/gst-libs/gst/webrtc/datachannel.c +++ b/gst-libs/gst/webrtc/datachannel.c @@ -84,6 +84,7 @@ gst_webrtc_data_channel_set_property (GObject * object, guint prop_id, GST_WEBRTC_DATA_CHANNEL_LOCK (channel); switch (prop_id) { case PROP_LABEL: + g_free (channel->label); channel->label = g_value_dup_string (value); break; case PROP_ORDERED: @@ -96,6 +97,7 @@ gst_webrtc_data_channel_set_property (GObject * object, guint prop_id, channel->max_retransmits = g_value_get_int (value); break; case PROP_PROTOCOL: + g_free (channel->protocol); channel->protocol = g_value_dup_string (value); break; case PROP_NEGOTIATED: