summaryrefslogtreecommitdiff
path: root/libupower-glib
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2015-06-17 10:52:12 +0200
committerBastien Nocera <hadess@hadess.net>2015-06-26 11:15:32 +0200
commitfe37183fba649b999af3f66b9e0b0d70a054426c (patch)
tree808a837041cf2d95ce99407220a65343504f960f /libupower-glib
parent95e8a2a316872bf5e6b262ccc3a165cca8240d27 (diff)
lib: Fix memory leak in up_client_get_devices()
When up_client_get_devices() fails to contact the D-Bus daemon, don't leak the newly created array.
Diffstat (limited to 'libupower-glib')
-rw-r--r--libupower-glib/up-client.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libupower-glib/up-client.c b/libupower-glib/up-client.c
index 48d99a0..4780aa5 100644
--- a/libupower-glib/up-client.c
+++ b/libupower-glib/up-client.c
@@ -95,8 +95,6 @@ up_client_get_devices (UpClient *client)
g_return_val_if_fail (UP_IS_CLIENT (client), NULL);
- array = g_ptr_array_new ();
-
if (up_client_glue_call_enumerate_devices_sync (client->priv->proxy,
&devices,
NULL,
@@ -106,6 +104,8 @@ up_client_get_devices (UpClient *client)
return NULL;
}
+ array = g_ptr_array_new ();
+
for (i = 0; devices[i] != NULL; i++) {
UpDevice *device;
const char *object_path = devices[i];