webrtc/datachannel: free previous protocol/label fields

Fixes a memory leak

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1535>
This commit is contained in:
Matthew Waters 2020-08-24 17:01:22 +10:00
parent e4b848e2a8
commit 7489addc0a
2 changed files with 4 additions and 0 deletions

View file

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

View file

@ -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: