[evolution-data-server] Bug #665036 - Memory leaks spot in Contacts view



commit 54e995a563fbbf2a3a81e71d4f3e020f19e43de2
Author: Milan Crha <mcrha redhat com>
Date:   Wed Jan 4 14:52:36 2012 +0100

    Bug #665036 - Memory leaks spot in Contacts view

 addressbook/backends/ldap/e-book-backend-ldap.c |   18 +++++++++++++++++-
 addressbook/libebook/e-destination.c            |    4 ++--
 addressbook/libebook/e-vcard.c                  |    5 ++++-
 libedataserver/e-proxy.c                        |   15 ++++++++-------
 4 files changed, 31 insertions(+), 11 deletions(-)
---
diff --git a/addressbook/backends/ldap/e-book-backend-ldap.c b/addressbook/backends/ldap/e-book-backend-ldap.c
index 38f2cfe..470f6ae 100644
--- a/addressbook/backends/ldap/e-book-backend-ldap.c
+++ b/addressbook/backends/ldap/e-book-backend-ldap.c
@@ -3133,6 +3133,9 @@ member_ber (EContact *contact)
 		}
 	}
 	result[i] = NULL;
+
+	g_list_free_full (members, (GDestroyNotify) e_vcard_attribute_free);
+
 	return result;
 }
 
@@ -3157,6 +3160,9 @@ member_compare (EContact *contact_new,
 	else
 		equal = (!!list_name1 == !!list_name2);
 
+	g_free (list_name1);
+	g_free (list_name2);
+
 	if (!equal)
 		return equal;
 
@@ -3164,8 +3170,12 @@ member_compare (EContact *contact_new,
 	len1 = g_list_length (members_new);
 	members_cur = e_contact_get_attributes (contact_current, E_CONTACT_EMAIL);
 	len2 = g_list_length (members_cur);
-	if (len1 != len2)
+	if (len1 != len2) {
+		g_list_free_full (members_new, (GDestroyNotify) e_vcard_attribute_free);
+		g_list_free_full (members_cur, (GDestroyNotify) e_vcard_attribute_free);
+
 		return FALSE;
+	}
 
 	for (l1 = members_new; l1 != NULL; l1 = g_list_next (l1)) {
 		EVCardAttribute *attr_new = l1->data;
@@ -3203,6 +3213,8 @@ member_compare (EContact *contact_new,
 						}
 					}
 					if (!found) {
+						g_list_free_full (members_new, (GDestroyNotify) e_vcard_attribute_free);
+						g_list_free_full (members_cur, (GDestroyNotify) e_vcard_attribute_free);
 						return FALSE;
 					}
 				}
@@ -3211,6 +3223,10 @@ member_compare (EContact *contact_new,
 		next_member:
 		continue;
 	}
+
+	g_list_free_full (members_new, (GDestroyNotify) e_vcard_attribute_free);
+	g_list_free_full (members_cur, (GDestroyNotify) e_vcard_attribute_free);
+
 	return TRUE;
 }
 
diff --git a/addressbook/libebook/e-destination.c b/addressbook/libebook/e-destination.c
index 9d0253e..d6dedd0 100644
--- a/addressbook/libebook/e-destination.c
+++ b/addressbook/libebook/e-destination.c
@@ -502,14 +502,14 @@ e_destination_set_contact (EDestination *dest,
 				if (attr->next) {
 					attr = attr->next;
 					if (remove) {
-						attrs = g_list_remove_link (attrs, attr->prev);
+						attrs = g_list_delete_link (attrs, attr->prev);
 						list_length--;
 					}
 					continue;
 				/* Or return to first attribute */
 				} else if (attrs) {
 					if (remove) {
-						attrs = g_list_remove_link (attrs, attr);
+						attrs = g_list_delete_link (attrs, attr);
 						list_length--;
 					}
 					attr = attrs;
diff --git a/addressbook/libebook/e-vcard.c b/addressbook/libebook/e-vcard.c
index 097dd7b..41d40bb 100644
--- a/addressbook/libebook/e-vcard.c
+++ b/addressbook/libebook/e-vcard.c
@@ -686,8 +686,11 @@ parse (EVCard *evc,
 			if (g_ascii_strcasecmp (next_attr->name, "end") == 0)
 				break;
 
-			if (ignore_uid && g_ascii_strcasecmp (attr->name, EVC_UID) == 0)
+			if (ignore_uid && g_ascii_strcasecmp (attr->name, EVC_UID) == 0) {
+				e_vcard_attribute_free (attr);
+				attr = NULL;
 				continue;
+			}
 
 			e_vcard_add_attribute (evc, next_attr);
 		}
diff --git a/libedataserver/e-proxy.c b/libedataserver/e-proxy.c
index f64a7d4..9790f04 100644
--- a/libedataserver/e-proxy.c
+++ b/libedataserver/e-proxy.c
@@ -1089,6 +1089,7 @@ SoupURI *
 e_proxy_peek_uri_for (EProxy *proxy,
                       const gchar *uri)
 {
+	SoupURI *res = NULL;
 	SoupURI *soup_uri;
 
 	g_return_val_if_fail (E_IS_PROXY (proxy), NULL);
@@ -1099,15 +1100,15 @@ e_proxy_peek_uri_for (EProxy *proxy,
 		return NULL;
 
 	if (soup_uri->scheme == SOUP_URI_SCHEME_HTTP)
-		return proxy->priv->uri_http;
-
-	if (soup_uri->scheme == SOUP_URI_SCHEME_HTTPS)
-		return proxy->priv->uri_https;
+		res = proxy->priv->uri_http;
+	else if (soup_uri->scheme == SOUP_URI_SCHEME_HTTPS)
+		res = proxy->priv->uri_https;
+	else if (soup_uri->scheme && g_ascii_strcasecmp (soup_uri->scheme, "socks") == 0)
+		res = proxy->priv->uri_socks;
 
-	if (soup_uri->scheme && g_ascii_strcasecmp (soup_uri->scheme, "socks") == 0)
-		return proxy->priv->uri_socks;
+	soup_uri_free (soup_uri);
 
-	return NULL;
+	return res;
 }
 
 /**



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