From 2c986ef102e13636cf56bbcb7a021b4236dc6cc2 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Mon, 10 Oct 2011 13:25:52 +0100 Subject: [PATCH] channel-contacts: guard against no-op updates process_contacts_queue() can already cope with ContactsQueueItems in the queue which do not actually have any contacts to prepare. As a comment in the function describes, we still go through the motions of enqueuing a preparation/upgrade operation to avoid reordering events. However, previously the function assumed that if any of the three arrays (of contact objects, ids, or handles) were non-NULL, then they would be non-empty. This assumption is false, as illustrates. The concrete example in that bug is an emission of MembersChanged, with all arrays except Removed empty, and Actor set to 0. We don't bother preparing contacts which are removed; so _tp_channel_contacts_queue_prepare_async() is called with an empty array of contacts. There are a few other signals which can lead to this situation. So this patch makes process_contacts_queue() do the right thing if the arrays are present but empty. (Previously all three paths would assert in this situation.) Fixes: --- telepathy-glib/channel-contacts.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/telepathy-glib/channel-contacts.c b/telepathy-glib/channel-contacts.c index 98bb096..f5de15b 100644 --- a/telepathy-glib/channel-contacts.c +++ b/telepathy-glib/channel-contacts.c @@ -370,7 +370,7 @@ process_contacts_queue (TpChannel *self) features = tp_simple_client_factory_dup_contact_features ( tp_proxy_get_factory (self->priv->connection), self->priv->connection); - if (item->contacts != NULL) + if (item->contacts != NULL && item->contacts->len > 0) { g_assert (item->ids == NULL); g_assert (item->handles == NULL); @@ -382,7 +382,7 @@ process_contacts_queue (TpChannel *self) item, NULL, (GObject *) self); } - else if (item->ids != NULL) + else if (item->ids != NULL && item->ids->len > 0) { g_assert (item->contacts == NULL); g_assert (item->handles == NULL); @@ -394,7 +394,7 @@ process_contacts_queue (TpChannel *self) item, NULL, (GObject *) self); } - else if (item->handles != NULL) + else if (item->handles != NULL && item->handles->len > 0) { g_assert (item->contacts == NULL); g_assert (item->ids == NULL); -- 1.7.5.4