summaryrefslogtreecommitdiff
path: root/agent/component.c
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2016-03-01 23:29:10 +0000
committerPhilip Withnall <philip@tecnocode.co.uk>2016-03-01 23:30:21 +0000
commitbc620c0de966b47d761bbcb1279dac6221a5a30e (patch)
tree9c3fd412c3dbc7e6f56f79700ec694d6546a2b27 /agent/component.c
parent38c5e66886cb8138d6be57b8a4721d9b42a358b7 (diff)
downloadlibnice-bc620c0de966b47d761bbcb1279dac6221a5a30e.tar.gz
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: José Antonio Santos Cadenas <santoscadenas@gmail.com> Differential Revision: https://phabricator.freedesktop.org/D822
Diffstat (limited to 'agent/component.c')
-rw-r--r--agent/component.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/agent/component.c b/agent/component.c
index d6712f4..f44b37d 100644
--- a/agent/component.c
+++ b/agent/component.c
@@ -98,6 +98,9 @@ socket_source_attach (SocketSource *socket_source, GMainContext *context)
{
GSource *source;
+ if (socket_source->socket->fileno == NULL)
+ return;
+
/* Create a source. */
source = g_socket_create_source (socket_source->socket->fileno,
G_IO_IN, NULL);
@@ -493,9 +496,6 @@ nice_component_attach_socket (NiceComponent *component, NiceSocket *nicesock)
g_assert (component->ctx != NULL);
- if (nicesock->fileno == NULL)
- return;
-
/* 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);
- component->socket_sources_age++;
+ if (nicesock->fileno != NULL)
+ component->socket_sources_age++;
}
/* 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)
+ continue;
+
/* 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.