socket: Avoid g_main_context_ref(NULL) calls using the default context
authorPhilip Withnall <philip.withnall@collabora.co.uk>
Wed, 2 Jul 2014 13:48:07 +0000 (14:48 +0100)
committerOlivier CrĂȘte <olivier.crete@collabora.com>
Mon, 7 Jul 2014 19:47:02 +0000 (15:47 -0400)
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
socket/tcp-passive.c

index 643c70e..e26e70d 100644 (file)
@@ -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);
index eeda236..a63a019 100644 (file)
@@ -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);