diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-10-18 16:44:38 +0200 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-10-18 16:44:40 +0200 |
commit | ba3cfa861786ba3c18f4759aa331b0a25a511b50 (patch) | |
tree | cd4ef488648b4065f1909915396370d426e92e4f | |
parent | b67a85de59ecf73ef80a7da81fa45e00287e8669 (diff) | |
download | telepathy-glib-ba3cfa861786ba3c18f4759aa331b0a25a511b50.tar.gz |
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
-rw-r--r-- | telepathy-glib/channel-contacts.c | 13 | ||||
-rw-r--r-- | 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 88f968f3c..011733363 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 90af03ddc..312dfe633 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; |