[gupnp/gupnp-1.0] connman: fix a potential crash



commit a1ad610b454dfa3db4a9011ff25bb10aaca22707
Author: Sven Neumann <neumann teufel de>
Date:   Fri Oct 2 16:19:44 2015 +0200

    connman: fix a potential crash
    
    cm_service_add() creates a CMService struct with a NULL
    service_proxy field and then uses the asynchronous
    g_dbus_proxy_new_for_bus() to create the proxy. So the
    service_proxy may be NULL when cm_service_free() is called
    before the proxy is actually created.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=770318

 libgupnp/gupnp-connman-manager.c |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/libgupnp/gupnp-connman-manager.c b/libgupnp/gupnp-connman-manager.c
index c8f1ba6..22fa8a5 100644
--- a/libgupnp/gupnp-connman-manager.c
+++ b/libgupnp/gupnp-connman-manager.c
@@ -268,17 +268,19 @@ cm_service_new (GUPnPConnmanManager *manager,
 static void
 cm_service_free (CMService *cm_service)
 {
-        GDBusConnection *cnx;
+        if (cm_service->proxy != NULL) {
+                GDBusConnection *cnx;
 
-        cnx = g_dbus_proxy_get_connection (cm_service->proxy);
+                cnx = g_dbus_proxy_get_connection (cm_service->proxy);
 
-        if (cm_service->sig_prop_id) {
-                g_dbus_connection_signal_unsubscribe (cnx,
-                                                      cm_service->sig_prop_id);
-                cm_service->sig_prop_id = 0;
-        }
+                if (cm_service->sig_prop_id) {
+                        g_dbus_connection_signal_unsubscribe (cnx,
+                                                              cm_service->sig_prop_id);
+                        cm_service->sig_prop_id = 0;
+                }
 
-        g_object_unref (cm_service->proxy);
+                g_object_unref (cm_service->proxy);
+        }
 
         service_context_remove_creation_timeout (cm_service);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]