[evolution] Bug #626579 - [bbdb] Crash in free_gaim_body() (gaimbuddies.c)



commit a96676f44616b7d4debe98efdeee2c6f2be1d033
Author: Milan Crha <mcrha redhat com>
Date:   Fri Sep 10 12:00:06 2010 +0200

    Bug #626579 - [bbdb] Crash in free_gaim_body() (gaimbuddies.c)

 plugins/bbdb/gaimbuddies.c |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)
---
diff --git a/plugins/bbdb/gaimbuddies.c b/plugins/bbdb/gaimbuddies.c
index 66f77bc..df5e4c3 100644
--- a/plugins/bbdb/gaimbuddies.c
+++ b/plugins/bbdb/gaimbuddies.c
@@ -345,7 +345,7 @@ static gboolean
 bbdb_merge_buddy_to_contact (EBook *book, GaimBuddy *b, EContact *c)
 {
 	EContactField field;
-	GList *ims, *l;
+	GList *ims;
 	gboolean dirty = FALSE;
 
 	EContactPhoto *photo = NULL;
@@ -356,11 +356,15 @@ bbdb_merge_buddy_to_contact (EBook *book, GaimBuddy *b, EContact *c)
 	field = proto_to_contact_field (b->proto);
 	ims = e_contact_get (c, field);
 	if (!im_list_contains_buddy (ims, b)) {
-		ims = g_list_append (ims, (gpointer) b->account_name);
+		ims = g_list_append (ims, g_strdup (b->account_name));
 		e_contact_set (c, field, (gpointer) ims);
 		dirty = TRUE;
 	}
 
+	g_list_foreach (ims, (GFunc) g_free, NULL);
+	g_list_free (ims);
+	ims = NULL;
+
         /* Set the photo if it's not set */
 	if (b->icon != NULL) {
 		photo = e_contact_get (c, E_CONTACT_PHOTO);
@@ -375,9 +379,6 @@ bbdb_merge_buddy_to_contact (EBook *book, GaimBuddy *b, EContact *c)
 				&photo->data.inlined.length, &error)) {
 				g_warning ("bbdb: Could not read buddy icon: %s\n", error->message);
 				g_error_free (error);
-				for (l = ims; l != NULL; l = l->next)
-					g_free ((gchar *) l->data);
-				g_list_free (ims);
 				return dirty;
 			}
 
@@ -391,10 +392,6 @@ bbdb_merge_buddy_to_contact (EBook *book, GaimBuddy *b, EContact *c)
 	if (photo != NULL)
 		e_contact_photo_free (photo);
 
-	for (l = ims; l != NULL; l = l->next)
-		g_free ((gchar *) l->data);
-	g_list_free (ims);
-
 	return dirty;
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]