summaryrefslogtreecommitdiff
path: root/libnm-glib/nm-object.c
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2014-07-31 09:21:05 -0400
committerDan Winship <danw@gnome.org>2014-08-01 12:12:42 -0400
commitfe264a2d01245d1cc814f5df6f86623bb8b35aef (patch)
tree045d41c6120b9d98859e7dc930fca8cb1f81d188 /libnm-glib/nm-object.c
parent08b91199fb95d9178feaeaa58381847332f22ad8 (diff)
downloadNetworkManager-fe264a2d01245d1cc814f5df6f86623bb8b35aef.tar.gz
libnm-glib: fix a crash when using multiple NMClients
NMObjectCache was assuming there would never be more than one object with the same path, but since NMClient is an NMObject, it was getting cached too, so if you created two clients and then unreffed one of them, it's possible the wrong one could get left in the cache, causing a crash the next time the other one called nm_object_cache_clear(). Fix this by only adding NMObjects to the cache in the codepaths where we also check to see if the object was already in the cache. (This also means we can remove the "except" argument to nm_object_cache_clear(), since the NMClient won't be cached any more.)
Diffstat (limited to 'libnm-glib/nm-object.c')
-rw-r--r--libnm-glib/nm-object.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libnm-glib/nm-object.c b/libnm-glib/nm-object.c
index e823baf43d..3550677df6 100644
--- a/libnm-glib/nm-object.c
+++ b/libnm-glib/nm-object.c
@@ -159,8 +159,6 @@ constructor (GType type,
return NULL;
}
- _nm_object_cache_add (NM_OBJECT (object));
-
return object;
}
@@ -573,6 +571,8 @@ _nm_object_create (GType type, DBusGConnection *connection, const char *path)
NM_OBJECT_DBUS_CONNECTION, connection,
NM_OBJECT_DBUS_PATH, path,
NULL);
+ if (NM_IS_OBJECT (object))
+ _nm_object_cache_add (NM_OBJECT (object));
if (!g_initable_init (G_INITABLE (object), NULL, &error)) {
dbgmsg ("Could not create object for %s: %s", path, error->message);
g_error_free (error);
@@ -656,6 +656,8 @@ async_got_type (GType type, gpointer user_data)
NM_OBJECT_DBUS_PATH, async_data->path,
NULL);
g_warn_if_fail (object != NULL);
+ if (NM_IS_OBJECT (object))
+ _nm_object_cache_add (NM_OBJECT (object));
g_async_initable_init_async (G_ASYNC_INITABLE (object), G_PRIORITY_DEFAULT,
NULL, async_inited, async_data);
}