diff options
author | Will Thompson <will.thompson@collabora.co.uk> | 2011-10-03 16:53:10 +0100 |
---|---|---|
committer | Will Thompson <will.thompson@collabora.co.uk> | 2011-10-04 14:37:02 +0100 |
commit | 904027787d6ae857e70f29b49f4d131a92e6500e (patch) | |
tree | 5d2978c7e1d6547633fa8439646c3d5509361e1e | |
parent | 746c6982d06a124b05b439f11d92ae24fa252a40 (diff) |
McdClient: don't allow unique_name to become NULL
_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: <https://bugs.freedesktop.org/show_bug.cgi?id=39767>
Reviewed-by: Xavier Claessens <xclaesse@gmail.com>
-rw-r--r-- | src/client-registry.c | 2 | ||||
-rw-r--r-- | 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 7bd18883..8b96bce5 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 a7ff0258..e3b1d08b 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); |