summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-10-18 16:44:38 +0200
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-10-18 16:44:40 +0200
commitba3cfa861786ba3c18f4759aa331b0a25a511b50 (patch)
treecd4ef488648b4065f1909915396370d426e92e4f
parentb67a85de59ecf73ef80a7da81fa45e00287e8669 (diff)
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.c13
-rw-r--r--telepathy-glib/channel-internal.h1
2 files changed, 13 insertions, 1 deletions
diff --git a/telepathy-glib/channel-contacts.c b/telepathy-glib/channel-contacts.c
index 88f968f3..01173336 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 90af03dd..312dfe63 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;