summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2014-09-08 14:11:28 -0400
committerDan Winship <danw@gnome.org>2014-09-17 08:21:21 -0400
commita59136878ae430c18e1770faee6322cc9a1c6e5c (patch)
treec9b6b6be60ed8ce2e971fc9c8af62274b3865727
parentad8b13091b3ccf6e87928039926c394903525bb2 (diff)
downloadNetworkManager-a59136878ae430c18e1770faee6322cc9a1c6e5c.tar.gz
libnm: fix object-creation-failure code
If _nm_object_create() hit an error, it would return the (half-initialized) object anyway. If _nm_object_create_async() hit an error, it would return NULL, but leak the half-initialized object. Fix both cases.
-rw-r--r--libnm/nm-object.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libnm/nm-object.c b/libnm/nm-object.c
index 8a014a65bd..3784fd15b5 100644
--- a/libnm/nm-object.c
+++ b/libnm/nm-object.c
@@ -559,6 +559,7 @@ _nm_object_create (GType type, DBusGConnection *connection, const char *path)
if (!g_initable_init (G_INITABLE (object), NULL, &error)) {
dbgmsg ("Could not create object for %s: %s", path, error->message);
g_error_free (error);
+ g_clear_object (&object);
}
return object;
@@ -591,7 +592,7 @@ async_inited (GObject *object, GAsyncResult *result, gpointer user_data)
nm_object_get_path (NM_OBJECT (object)),
error->message);
g_error_free (error);
- object = NULL;
+ g_clear_object (&object);
}
create_async_complete (object, async_data);