Commit bc620c0d authored by Olivier Crête's avatar Olivier Crête Committed by Philip Withnall

component.c: Fix memory leak

If nicesocket is not added to a component it will be leaked.

This is the case of active tcp sockets

Change-Id: I57fefffef71d35ce9871139ee1064181f6fe125b
Reviewed-by: default avatarJosé Antonio Santos Cadenas <>
Differential Revision:
parent 38c5e668
......@@ -98,6 +98,9 @@ socket_source_attach (SocketSource *socket_source, GMainContext *context)
GSource *source;
if (socket_source->socket->fileno == NULL)
/* Create a source. */
source = g_socket_create_source (socket_source->socket->fileno,
......@@ -493,9 +496,6 @@ nice_component_attach_socket (NiceComponent *component, NiceSocket *nicesock)
g_assert (component->ctx != NULL);
if (nicesock->fileno == NULL)
/* Find an existing SocketSource in the component which contains @socket, or
* create a new one.
......@@ -512,7 +512,8 @@ nice_component_attach_socket (NiceComponent *component, NiceSocket *nicesock)
socket_source->component = component;
component->socket_sources =
g_slist_prepend (component->socket_sources, socket_source);
if (nicesock->fileno != NULL)
/* Create and attach a source */
......@@ -1160,6 +1161,9 @@ component_source_prepare (GSource *source, gint *timeout_)
SocketSource *parent_socket_source = parentl->data;
SocketSource *child_socket_source;
if (parent_socket_source->socket->fileno == NULL)
/* Iterating the list of socket sources every time isn't a big problem
* because the number of pairs is limited ~100 normally, so there will
* rarely be more than 10.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment