From 0313474daf288bd973ea491c530d26dd2df0fd28 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Wed, 24 Nov 2010 12:00:11 +0100 Subject: empathy_message_from_tpl_log_entry: don't leak receiver and sender --- libempathy/empathy-message.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/libempathy/empathy-message.c b/libempathy/empathy-message.c index 0ac6e01b5..ca3b020ac 100644 --- a/libempathy/empathy-message.c +++ b/libempathy/empathy-message.c @@ -267,6 +267,7 @@ empathy_message_from_tpl_log_entry (TplEntry *logentry) TplEntity *receiver = NULL; TplEntity *sender = NULL; gchar *body= NULL; + EmpathyContact *contact; g_return_val_if_fail (TPL_IS_ENTRY (logentry), NULL); @@ -303,12 +304,17 @@ empathy_message_from_tpl_log_entry (TplEntry *logentry) sender = tpl_entry_get_sender (logentry); retval = empathy_message_new (body); - if (receiver != NULL) - empathy_message_set_receiver (retval, - empathy_contact_from_tpl_contact (account, receiver)); - if (sender != NULL) - empathy_message_set_sender (retval, - empathy_contact_from_tpl_contact (account, sender)); + if (receiver != NULL) { + contact = empathy_contact_from_tpl_contact (account, receiver); + empathy_message_set_receiver (retval, contact); + g_object_unref (contact); + } + + if (sender != NULL) { + contact = empathy_contact_from_tpl_contact (account, sender); + empathy_message_set_sender (retval, contact); + g_object_unref (contact); + } empathy_message_set_timestamp (retval, tpl_entry_get_timestamp (logentry)); -- cgit v1.2.3