From ba3cfa861786ba3c18f4759aa331b0a25a511b50 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 18 Oct 2011 16:44:38 +0200 Subject: [PATCH] deal with self->priv->group_contact_owners may containing NULL contact If the owner is unknown self->priv->group_contact_owners may contain NULL TpContact. g_object_unref() not being NULL safe we have to use our own value_destroy_func to avoid warnings. https://bugs.freedesktop.org/show_bug.cgi?id=41928 --- telepathy-glib/channel-contacts.c | 13 ++++++++++++- telepathy-glib/channel-internal.h | 1 + 2 files changed, 13 insertions(+), 1 deletions(-) diff --git a/telepathy-glib/channel-contacts.c b/telepathy-glib/channel-contacts.c index 88f968f..0117333 100644 --- a/telepathy-glib/channel-contacts.c +++ b/telepathy-glib/channel-contacts.c @@ -108,6 +108,17 @@ dup_contacts_table (TpChannel *self, return target; } +/* self->priv->group_contact_owners may contain NULL TpContact and + * g_object_unref isn't NULL safe */ +static void +safe_g_object_unref (gpointer data) +{ + if (data == NULL) + return; + + g_object_unref (data); +} + static GHashTable * dup_owners_table (TpChannel *self, GHashTable *source, @@ -117,7 +128,7 @@ dup_owners_table (TpChannel *self, GHashTableIter iter; gpointer key, value; - target = g_hash_table_new_full (NULL, NULL, NULL, g_object_unref); + target = g_hash_table_new_full (NULL, NULL, NULL, safe_g_object_unref); g_hash_table_iter_init (&iter, source); while (g_hash_table_iter_next (&iter, &key, &value)) diff --git a/telepathy-glib/channel-internal.h b/telepathy-glib/channel-internal.h index 90af03d..312dfe6 100644 --- a/telepathy-glib/channel-internal.h +++ b/telepathy-glib/channel-internal.h @@ -82,6 +82,7 @@ struct _TpChannelPrivate { GHashTable *group_members_contacts; GHashTable *group_local_pending_contacts; GHashTable *group_remote_pending_contacts; + /* the TpContact can be NULL if the owner is unknown */ GHashTable *group_contact_owners; gboolean cm_too_old_for_contacts; -- 1.7.4.1