From e28a24207f09cfac4ac294d4a48fb587f1da76d9 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 4 Jan 2013 17:33:14 +0000 Subject: [PATCH 7/7] Names mixin: in legacy SetAliases, early-return on invalid handles --- telepathy-glib/names-mixin.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/telepathy-glib/names-mixin.c b/telepathy-glib/names-mixin.c index 93fb0bc..46ea438 100644 --- a/telepathy-glib/names-mixin.c +++ b/telepathy-glib/names-mixin.c @@ -742,15 +742,21 @@ tp_names_mixin_aliasing_set_aliases ( TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (base, context); g_hash_table_iter_init (&iter, table); + + while (g_hash_table_iter_next (&iter, &key, NULL)) + { + TpHandle contact = GPOINTER_TO_UINT (key); + + if (!tp_handle_is_valid (contact_repo, contact, &error)) + goto out; + } + + g_hash_table_iter_init (&iter, table); while (g_hash_table_iter_next (&iter, &key, &value)) { TpHandle contact = GPOINTER_TO_UINT (key); const gchar *alias = value; - if (!tp_handle_is_valid (contact_repo, contact, - (error == NULL) ? &error : NULL)) - continue; - /* Even if setting the local alias fails, we want to keep it for at least * the session */ tp_names_mixin_one_local_alias_changed (base, contact, alias); @@ -759,6 +765,7 @@ tp_names_mixin_aliasing_set_aliases ( iface->set_local_alias_async (base, contact, alias, NULL, NULL); } +out: if (error != NULL) { dbus_g_method_return_error (context, error); -- 1.7.10.4