[evolution-couchdb] Fixed leak when getting email addresses from EContact's



commit 6950514b9c17a6d3451cacf53f2313c651f81dda
Author: Rodrigo Moya <rodrigo gnome-db org>
Date:   Tue Apr 6 20:07:58 2010 +0200

    Fixed leak when getting email addresses from EContact's

 addressbook/e-book-backend-couchdb.c |   27 ++++++++++++++++-----------
 1 files changed, 16 insertions(+), 11 deletions(-)
---
diff --git a/addressbook/e-book-backend-couchdb.c b/addressbook/e-book-backend-couchdb.c
index dee5757..a330b3e 100644
--- a/addressbook/e-book-backend-couchdb.c
+++ b/addressbook/e-book-backend-couchdb.c
@@ -754,20 +754,25 @@ couch_document_from_contact (EBookBackendCouchDB *couchdb_backend, EContact *con
 	/* email addresses */
 	list = NULL;
 	attr_list = e_contact_get_attributes (contact, E_CONTACT_EMAIL);
-	for (al = attr_list; al != NULL; al = al->next) {
-		CouchdbStructField *sf;
-		EVCardAttribute *attr = (EVCardAttribute *) al->data;
+	if (attr_list != NULL) {
+		for (al = attr_list; al != NULL; al = al->next) {
+			CouchdbStructField *sf;
+			EVCardAttribute *attr = (EVCardAttribute *) al->data;
 
-		sf = contact_email_to_struct_field (attr);
-		if (sf)
-			list = g_slist_append (list, sf);
-	}
+			sf = contact_email_to_struct_field (attr);
+			if (sf)
+				list = g_slist_append (list, sf);
+		}
 
-	if (list) {
-		desktopcouch_document_contact_set_email_addresses (document, list);
+		if (list) {
+			desktopcouch_document_contact_set_email_addresses (document, list);
 
-		g_slist_foreach (list, (GFunc) couchdb_struct_field_unref, NULL);
-		g_slist_free (list);
+			g_slist_foreach (list, (GFunc) couchdb_struct_field_unref, NULL);
+			g_slist_free (list);
+		}
+
+		g_list_foreach (attr_list, (GFunc) e_vcard_attribute_free, NULL);
+		g_list_free (attr_list);
 	}
 
 	/* phone numbers */



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