[evolution] Fix some memory leaks



commit 88a372b27e655eaaa27e7b806a1adc360b1583b6
Author: Dan VrÃtil <dvratil redhat com>
Date:   Fri Jun 15 16:49:26 2012 +0200

    Fix some memory leaks

 mail/e-mail-backend.c     |   11 +++++++++--
 mail/e-mail-display.c     |   17 ++++++++---------
 mail/e-mail-request.c     |    1 +
 widgets/misc/e-web-view.c |    3 +++
 4 files changed, 21 insertions(+), 11 deletions(-)
---
diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c
index 19150cc..b0e4326 100644
--- a/mail/e-mail-backend.c
+++ b/mail/e-mail-backend.c
@@ -654,11 +654,15 @@ mail_backend_folder_changed_cb (MailFolderCache *folder_cache,
 		CamelFolder *folder = NULL;
 
 		if (mail_folder_cache_get_folder_from_uri (
-				folder_cache, folder_uri, &folder))
+				folder_cache, folder_uri, &folder)) {
 			if (folder != NULL &&
 				!mail_folder_cache_get_folder_info_flags (
-				folder_cache, folder, &flags))
+				folder_cache, folder, &flags)) {
+				g_free (folder_uri);
 				g_return_if_reached ();
+			}
+		}
+
 		if (folder != NULL)
 			g_object_unref (folder);
 	}
@@ -667,6 +671,9 @@ mail_backend_folder_changed_cb (MailFolderCache *folder_cache,
 		event, store, folder_uri, new_messages,
 		msg_uid, msg_sender, msg_subject);
 
+	if (folder_uri)
+		g_free (folder_uri);
+
 	folder_type = (flags & CAMEL_FOLDER_TYPE_MASK);
 	target->is_inbox = (folder_type == CAMEL_FOLDER_TYPE_INBOX);
 
diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c
index 1ca8bcc..461fb8f 100644
--- a/mail/e-mail-display.c
+++ b/mail/e-mail-display.c
@@ -1680,7 +1680,6 @@ e_mail_display_reload (EMailDisplay *display)
 	GHashTable *table;
 	GHashTableIter table_iter;
 	gpointer key, val;
-	gchar separator;
 
 	g_return_if_fail (E_IS_MAIL_DISPLAY (display));
 
@@ -1695,23 +1694,23 @@ e_mail_display_reload (EMailDisplay *display)
 		return;
 	}
 
-	base = g_strndup (uri, strstr (uri, "?") - uri);
+	base = g_strndup (uri, strstr (uri, "?") - uri + 1);
 	new_uri = g_string_new (base);
 	g_free (base);
 
 	table = soup_form_decode (strstr (uri, "?") + 1);
-	g_hash_table_insert (table, g_strdup ("mode"), g_strdup_printf ("%d", display->priv->mode));
-	g_hash_table_insert (table, g_strdup ("headers_collapsable"), g_strdup_printf ("%d", display->priv->headers_collapsable));
-	g_hash_table_insert (table, g_strdup ("headers_collapsed"), g_strdup_printf ("%d", display->priv->headers_collapsed));
+	g_hash_table_replace (table, g_strdup ("mode"), g_strdup_printf ("%d", display->priv->mode));
+	g_hash_table_replace (table, g_strdup ("headers_collapsable"), g_strdup_printf ("%d", display->priv->headers_collapsable));
+	g_hash_table_replace (table, g_strdup ("headers_collapsed"), g_strdup_printf ("%d", display->priv->headers_collapsed));
 
 	g_hash_table_iter_init (&table_iter, table);
-	separator = '?';
 	while (g_hash_table_iter_next (&table_iter, &key, &val)) {
-		g_string_append_printf (new_uri, "%c%s=%s", separator,
+		g_string_append_printf (new_uri, "%s=%s&",
 			(gchar *) key, (gchar *) val);
 
-	if (separator == '?')
-		separator = '&';
+		/* Free the value as Soup constructs the GHashTable without
+		 * value_destroy_func */
+		g_free (val);
 	}
 
 	e_web_view_load_uri (web_view, new_uri->str);
diff --git a/mail/e-mail-request.c b/mail/e-mail-request.c
index 5805a10..544f5f3 100644
--- a/mail/e-mail-request.c
+++ b/mail/e-mail-request.c
@@ -228,6 +228,7 @@ handle_contact_photo_request (GSimpleAsyncResult *res,
 	camel_address_decode ((CamelAddress *) cia, (const gchar *) photo_name);
 	photopart = em_utils_contact_photo (
 			registry, cia, only_local_photo, cancellable);
+	g_object_unref (cia);
 	if (!photopart) {
 		gsize len;
 
diff --git a/widgets/misc/e-web-view.c b/widgets/misc/e-web-view.c
index 956f721..f3728db 100644
--- a/widgets/misc/e-web-view.c
+++ b/widgets/misc/e-web-view.c
@@ -937,6 +937,8 @@ web_view_button_press_event (GtkWidget *widget,
 				break;
 			}
 		}
+
+		g_object_unref (test);
 	}
 
 	if (event != NULL && event->button != 3)
@@ -1062,6 +1064,7 @@ web_view_extract_uri (EWebView *web_view,
 		WEBKIT_WEB_VIEW (web_view), event);
 
 	g_object_get (result, "context", &context, "link-uri", &uri, NULL);
+	g_object_unref (result);
 
 	if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK)
 		return uri;



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