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:47 -0800
commit087d227daff0f62009bdd81c6d56bfd7af5f6f1f (patch)
tree0762b5dcec3295fcf8dd788156f8de48f81023c8 /gdbus
parentf2e9dce4d5e2bc7610d71b90b4513634d5157c87 (diff)
downloadconnman-087d227daff0f62009bdd81c6d56bfd7af5f6f1f.tar.gz
connman-087d227daff0f62009bdd81c6d56bfd7af5f6f1f.tar.bz2
connman-087d227daff0f62009bdd81c6d56bfd7af5f6f1f.zip
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)