diff options
author | Rick Bell <richard.s.bell@intel.com> | 2015-03-24 12:29:51 -0700 |
---|---|---|
committer | Rick Bell <richard.s.bell@intel.com> | 2015-03-24 12:29:51 -0700 |
commit | 525e167b4699b3fa84bf44830a37db128e640c5b (patch) | |
tree | 7a70b4579c2af0bdebab30c351561a8a9d295ec3 | |
parent | d1ca461ad859615cf07df677e7c98b942a1b992e (diff) | |
parent | 00870c6f44b68582c98cb36e73297f014c269f95 (diff) | |
download | dleyna-connector-dbus-525e167b4699b3fa84bf44830a37db128e640c5b.tar.gz |
Merge pull request #10 from debarshiray/master
Don't crash when trying to unwatch non-existent client
-rw-r--r-- | src/connector-dbus.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/connector-dbus.c b/src/connector-dbus.c index 0e16239..83774c0 100644 --- a/src/connector-dbus.c +++ b/src/connector-dbus.c @@ -173,7 +173,7 @@ static gboolean prv_connector_initialize(const gchar *server_info, g_context.objects = g_hash_table_new_full(g_direct_hash, g_direct_equal, g_free, prv_free_dbus_object); g_context.clients = g_hash_table_new_full(g_str_hash, g_str_equal, - g_free, g_free); + g_free, NULL); g_context.root_node_info = g_dbus_node_info_new_for_xml(root_info, NULL); @@ -268,8 +268,8 @@ static void prv_connector_unwatch_client(const gchar *client_name) DLEYNA_LOG_DEBUG("Enter"); - client_id = *(guint *)g_hash_table_lookup(g_context.clients, - client_name); + client_id = GPOINTER_TO_UINT(g_hash_table_lookup(g_context.clients, + client_name)); (void) g_hash_table_remove(g_context.clients, client_name); g_bus_unwatch_name(client_id); @@ -287,7 +287,6 @@ static void prv_lost_client(GDBusConnection *connection, const gchar *name, static gboolean prv_connector_watch_client(const gchar *client_name) { guint watch_id; - guint *client_id; gboolean added = TRUE; DLEYNA_LOG_DEBUG("Enter"); @@ -301,10 +300,8 @@ static gboolean prv_connector_watch_client(const gchar *client_name) G_BUS_NAME_WATCHER_FLAGS_NONE, NULL, prv_lost_client, NULL, NULL); - client_id = g_new(guint, 1); - *client_id = watch_id; g_hash_table_insert(g_context.clients, g_strdup(client_name), - client_id); + GUINT_TO_POINTER(watch_id)); out: DLEYNA_LOG_DEBUG("Exit"); |