From 904027787d6ae857e70f29b49f4d131a92e6500e Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Mon, 3 Oct 2011 16:53:10 +0100 Subject: [PATCH] McdClient: don't allow unique_name to become NULL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _mcd_client_registry_found_name() is called in three situations: • the initial call to ListNames() has returned; • the initial call to ListActivatableNames() has returned; and • NameOwnerChanged has been emitted for a client-shaped well-known name. In the first two cases, unique_name_if_known is NULL; in the first case, activatable is FALSE. I don't really understand what business the McdClientRegistry has telling the McdClient what its unique name is even when it's non-NULL, but passing NULL to _mcd_client_proxy_set_active() made McdClient violate an internal invariant. The first action McdClient takes is to discover the client's unique name, if any; if the client is not running, unique_name is set to "" (not NULL). Other parts of the McdClient internals assume (and assert) that unique_name is not NULL by the time they run. I *believe* that the client registry need not ever call _mcd_client_proxy_set_active(), but I am loathe to make that change without fully understanding the code and writing some tests. Fixes: Reviewed-by: Xavier Claessens --- src/client-registry.c | 2 +- src/mcd-client.c | 1 + 2 files changed, 2 insertions(+), 1 deletions(-) diff --git a/src/client-registry.c b/src/client-registry.c index 7bd1888..8b96bce 100644 --- a/src/client-registry.c +++ b/src/client-registry.c @@ -142,7 +142,7 @@ _mcd_client_registry_found_name (McdClientRegistry *self, * it is activatable */ _mcd_client_proxy_set_activatable (client); } - else + else if (unique_name_if_known != NULL) { /* We already knew that it was activatable, but now we also know * that it is active */ diff --git a/src/mcd-client.c b/src/mcd-client.c index a7ff025..e3b1d08 100644 --- a/src/mcd-client.c +++ b/src/mcd-client.c @@ -1326,6 +1326,7 @@ _mcd_client_proxy_set_active (McdClientProxy *self, const gchar *unique_name) { g_return_if_fail (MCD_IS_CLIENT_PROXY (self)); + g_return_if_fail (unique_name != NULL); g_free (self->priv->unique_name); self->priv->unique_name = g_strdup (unique_name); -- 1.7.5.4