summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.co.uk>2012-04-16 17:42:33 +0200
committerXavier Claessens <xavier.claessens@collabora.co.uk>2012-04-16 18:27:12 +0200
commit57e23d6d7788498061349649e9b4bccf9ea7bf7b (patch)
treed9243d14e5ebb2615417cd68fe52f2f1b502cc7a
parent66d1a078e9d52791ad53db2ce7a94e817e86d12e (diff)
downloadtelepathy-glib-57e23d6d7788498061349649e9b4bccf9ea7bf7b.tar.gz
Do not use _tp_connection_lookup_contact() outside contact.c
That function is dangerous because it does not guarantee that the returned TpContact has an identifier set. In the case a TpContact is being created with tp_connection_get_contacts_by_id(), the first step is to inspect its handle and then create the TpContact object *without* giving its ID. The id will be set later once we got the contact attributes. If _tp_connection_lookup_contact() is called for the same handle/id between the moment the TpContact is created and the moment it sets its attributes, then a contact with no identifier is returned.
-rw-r--r--telepathy-glib/call-channel.c7
-rw-r--r--telepathy-glib/simple-client-factory.c5
2 files changed, 7 insertions, 5 deletions
diff --git a/telepathy-glib/call-channel.c b/telepathy-glib/call-channel.c
index 6e88061fd..81a2a49eb 100644
--- a/telepathy-glib/call-channel.c
+++ b/telepathy-glib/call-channel.c
@@ -77,7 +77,7 @@ struct _TpCallChannelPrivate
GHashTable *state_details;
TpCallStateReason *state_reason;
gboolean hardware_streaming;
- /* TpHandle -> TpCallMemberFlags */
+ /* TpContact -> TpCallMemberFlags */
GHashTable *members;
gboolean initial_audio;
gboolean initial_video;
@@ -270,14 +270,15 @@ _tp_call_members_convert_array (TpConnection *connection,
TpContact *contact;
/* The contact is supposed to already exists */
- contact = _tp_connection_lookup_contact (connection, handle);
+ contact = tp_connection_dup_contact_if_possible (connection,
+ handle, NULL);
if (contact == NULL)
{
DEBUG ("No TpContact found for handle %u", handle);
continue;
}
- g_ptr_array_add (result, g_object_ref (contact));
+ g_ptr_array_add (result, contact);
}
return result;
diff --git a/telepathy-glib/simple-client-factory.c b/telepathy-glib/simple-client-factory.c
index 57fb9aff3..fa8fd0431 100644
--- a/telepathy-glib/simple-client-factory.c
+++ b/telepathy-glib/simple-client-factory.c
@@ -849,9 +849,10 @@ tp_simple_client_factory_ensure_contact (TpSimpleClientFactory *self,
g_return_val_if_fail (handle != 0, NULL);
g_return_val_if_fail (identifier != NULL, NULL);
- contact = _tp_connection_lookup_contact (connection, handle);
+ contact = tp_connection_dup_contact_if_possible (connection,
+ handle, identifier);
if (contact != NULL)
- return g_object_ref (contact);
+ return contact;
contact = TP_SIMPLE_CLIENT_FACTORY_GET_CLASS (self)->create_contact (self,
connection, handle, identifier);