From 88c68debdc5f29f29d8ba031ba7d66fbc109314d Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 2 Jul 2014 14:48:07 +0100 Subject: [PATCH] socket: Avoid g_main_context_ref(NULL) calls using the default context If (agent->main_context == NULL) the sockets are created with a NULL main context, which they then try to ref. That does not end well. --- socket/tcp-active.c | 4 ++++ socket/tcp-passive.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/socket/tcp-active.c b/socket/tcp-active.c index 643c70e..e26e70d 100644 --- a/socket/tcp-active.c +++ b/socket/tcp-active.c @@ -101,6 +101,10 @@ nice_tcp_active_socket_new (GMainContext *ctx, NiceAddress *addr, return NULL; } + if (ctx == NULL) { + ctx = g_main_context_default (); + } + sock = g_slice_new0 (NiceSocket); sock->priv = priv = g_slice_new0 (TcpActivePriv); diff --git a/socket/tcp-passive.c b/socket/tcp-passive.c index eeda236..a63a019 100644 --- a/socket/tcp-passive.c +++ b/socket/tcp-passive.c @@ -147,6 +147,10 @@ nice_tcp_passive_socket_new (GMainContext *ctx, NiceAddress *addr, } g_object_unref (gaddr); + if (ctx == NULL) { + ctx = g_main_context_default (); + } + sock = g_slice_new0 (NiceSocket); nice_address_set_from_sockaddr (&sock->addr, &name.addr); -- 2.7.4