From 10ea7a911ce66c8f70eb811b61c9c75682df541c Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 1 Jun 2011 12:52:20 -0500 Subject: [PATCH] libnm-glib: fix up empty object path demarshalling after 8afce8590ab8f08f0703a9f0a4cf8c6fbfe87fb6 G_VALUE_HOLDS will fail if the value variable is NULL, so we only want to check that the GValue holds the right type if the value is valid. NULL means "no object path" in demarshallers. --- libnm-glib/nm-device-wifi.c | 10 +++++----- libnm-glib/nm-device-wimax.c | 10 +++++----- libnm-glib/nm-device.c | 30 +++++++++++++++--------------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/libnm-glib/nm-device-wifi.c b/libnm-glib/nm-device-wifi.c index 9877f94ff..7d0e1b9f6 100644 --- a/libnm-glib/nm-device-wifi.c +++ b/libnm-glib/nm-device-wifi.c @@ -637,12 +637,10 @@ demarshal_active_ap (NMObject *object, GParamSpec *pspec, GValue *value, gpointe NMAccessPoint *ap = NULL; DBusGConnection *connection; - if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH)) - return FALSE; - - priv->got_active_ap = TRUE; - if (value) { + if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH)) + return FALSE; + path = g_value_get_boxed (value); if (path) { ap = NM_ACCESS_POINT (_nm_object_cache_get (path)); @@ -653,6 +651,8 @@ demarshal_active_ap (NMObject *object, GParamSpec *pspec, GValue *value, gpointe } } + priv->got_active_ap = TRUE; + if (priv->active_ap) { g_object_unref (priv->active_ap); priv->active_ap = NULL; diff --git a/libnm-glib/nm-device-wimax.c b/libnm-glib/nm-device-wimax.c index a889583db..4844a0e21 100644 --- a/libnm-glib/nm-device-wimax.c +++ b/libnm-glib/nm-device-wimax.c @@ -628,12 +628,10 @@ demarshal_active_nsp (NMObject *object, GParamSpec *pspec, GValue *value, gpoint NMWimaxNsp *nsp = NULL; DBusGConnection *connection; - if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH)) - return FALSE; - - priv->got_active_nsp = TRUE; - if (value) { + if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH)) + return FALSE; + path = g_value_get_boxed (value); if (path) { nsp = NM_WIMAX_NSP (_nm_object_cache_get (path)); @@ -644,6 +642,8 @@ demarshal_active_nsp (NMObject *object, GParamSpec *pspec, GValue *value, gpoint } } + priv->got_active_nsp = TRUE; + if (priv->active_nsp) { g_object_unref (priv->active_nsp); priv->active_nsp = NULL; diff --git a/libnm-glib/nm-device.c b/libnm-glib/nm-device.c index 3b39c9ece..9ac6fe3ce 100644 --- a/libnm-glib/nm-device.c +++ b/libnm-glib/nm-device.c @@ -120,12 +120,10 @@ demarshal_ip4_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoint NMIP4Config *config = NULL; DBusGConnection *connection; - if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH)) - return FALSE; - - priv->got_ip4_config = TRUE; - if (value) { + if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH)) + return FALSE; + path = g_value_get_boxed (value); if (path) { config = NM_IP4_CONFIG (_nm_object_cache_get (path)); @@ -136,6 +134,8 @@ demarshal_ip4_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoint } } + priv->got_ip4_config = TRUE; + if (priv->ip4_config) { g_object_unref (priv->ip4_config); priv->ip4_config = NULL; @@ -156,12 +156,10 @@ demarshal_dhcp4_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoi NMDHCP4Config *config = NULL; DBusGConnection *connection; - if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH)) - return FALSE; - - priv->got_dhcp4_config = TRUE; - if (value) { + if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH)) + return FALSE; + path = g_value_get_boxed (value); if (path) { config = NM_DHCP4_CONFIG (_nm_object_cache_get (path)); @@ -172,6 +170,8 @@ demarshal_dhcp4_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoi } } + priv->got_dhcp4_config = TRUE; + if (priv->dhcp4_config) { g_object_unref (priv->dhcp4_config); priv->dhcp4_config = NULL; @@ -192,12 +192,10 @@ demarshal_ip6_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoint NMIP6Config *config = NULL; DBusGConnection *connection; - if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH)) - return FALSE; - - priv->got_ip6_config = TRUE; - if (value) { + if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH)) + return FALSE; + path = g_value_get_boxed (value); if (path) { config = NM_IP6_CONFIG (_nm_object_cache_get (path)); @@ -208,6 +206,8 @@ demarshal_ip6_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoint } } + priv->got_ip6_config = TRUE; + if (priv->ip6_config) { g_object_unref (priv->ip6_config); priv->ip6_config = NULL;