summaryrefslogtreecommitdiff
path: root/gdbus
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2012-12-29 11:57:05 -0800
committerMarcel Holtmann <marcel@holtmann.org>2012-12-29 14:49:37 -0800
commitcdd1febd4d0c82b30d993deb6c049713e3e10dae (patch)
treea151dbc5b302dc3fb6bd2f2b8c6f5304db90a73d /gdbus
parent9ba681ddcdfb78418e4b7780c2d99a7f0f1816d0 (diff)
gdbus: Protect standalone proxy creation with client reference
Diffstat (limited to 'gdbus')
-rw-r--r--gdbus/client.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/gdbus/client.c b/gdbus/client.c
index 536121f3..8d2a7513 100644
--- a/gdbus/client.c
+++ b/gdbus/client.c
@@ -261,6 +261,7 @@ static void update_properties(GDBusProxy *proxy, DBusMessageIter *iter)
static void get_all_properties_reply(DBusPendingCall *call, void *user_data)
{
GDBusProxy *proxy = user_data;
+ GDBusClient *client = proxy->client;
DBusMessage *reply = dbus_pending_call_steal_reply(call);
DBusMessageIter iter;
DBusError error;
@@ -277,17 +278,14 @@ static void get_all_properties_reply(DBusPendingCall *call, void *user_data)
update_properties(proxy, &iter);
done:
- if (proxy->client != NULL) {
- GDBusClient *client = proxy->client;
-
- if (client->proxy_added)
- client->proxy_added(proxy, client->user_data);
+ if (client->proxy_added)
+ client->proxy_added(proxy, client->user_data);
- client->proxy_list = g_list_append(client->proxy_list, proxy);
- } else
- g_dbus_proxy_unref(proxy);
+ client->proxy_list = g_list_append(client->proxy_list, proxy);
dbus_message_unref(reply);
+
+ g_dbus_client_unref(client);
}
static void get_all_properties(GDBusProxy *proxy)
@@ -311,7 +309,7 @@ static void get_all_properties(GDBusProxy *proxy)
return;
}
- g_dbus_proxy_ref(proxy);
+ g_dbus_client_ref(client);
dbus_pending_call_set_notify(call, get_all_properties_reply,
proxy, NULL);
@@ -425,7 +423,7 @@ GDBusProxy *g_dbus_proxy_new(GDBusClient *client, const char *path,
get_all_properties(proxy);
- return proxy;
+ return g_dbus_proxy_ref(proxy);
}
GDBusProxy *g_dbus_proxy_ref(GDBusProxy *proxy)