[evolution] Bug #603342 - Memory leak fixes
- From: Milan Crha <mcrha src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution] Bug #603342 - Memory leak fixes
- Date: Tue, 15 Dec 2009 10:13:19 +0000 (UTC)
commit 859c8b5a8fae36bdb615f35f792c8256d4c8f97e
Author: Milan Crha <mcrha redhat com>
Date: Tue Dec 15 11:12:41 2009 +0100
Bug #603342 - Memory leak fixes
composer/e-composer-header.c | 1 +
mail/em-format-html-display.c | 4 ++--
modules/calendar/e-cal-shell-view-private.c | 10 ++++++----
plugins/templates/templates.c | 1 +
shell/e-shell-settings.c | 3 +++
smime/gui/certificate-manager.c | 6 +++++-
smime/lib/e-cert-db.c | 9 ++++++---
smime/lib/e-cert.c | 17 +++++++++++++++--
8 files changed, 39 insertions(+), 12 deletions(-)
---
diff --git a/composer/e-composer-header.c b/composer/e-composer-header.c
index 36d0ffb..f80a818 100644
--- a/composer/e-composer-header.c
+++ b/composer/e-composer-header.c
@@ -114,6 +114,7 @@ composer_header_constructor (GType type,
tmp = gtk_label_new (NULL);
str = g_strdup_printf ("<span foreground='blue' underline='single' underline_color='blue' >%s</span>", header->priv->addaction_text);
gtk_label_set_markup((GtkLabel *)tmp, str);
+ g_free (str);
gtk_box_pack_start((GtkBox *)box, tmp, FALSE, FALSE, 3);
gtk_container_add((GtkContainer *)header->action_widget, box);
gtk_widget_show_all(header->action_widget);
diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c
index f2f001e..9519707 100644
--- a/mail/em-format-html-display.c
+++ b/mail/em-format-html-display.c
@@ -193,7 +193,7 @@ efhd_xpkcs7mime_viewcert_clicked (GtkWidget *button,
ECert *ec = NULL;
if (info->cert_data)
- ec = e_cert_new (info->cert_data);
+ ec = e_cert_new (CERT_DupCertificate (info->cert_data));
if (ec != NULL) {
GtkWidget *w = certificate_viewer_show(ec);
@@ -251,7 +251,7 @@ efhd_xpkcs7mime_add_cert_table (GtkWidget *vbox,
g_signal_connect(w, "clicked", G_CALLBACK(efhd_xpkcs7mime_viewcert_clicked), po);
if (info->cert_data)
- ec = e_cert_new (info->cert_data);
+ ec = e_cert_new (CERT_DupCertificate (info->cert_data));
if (ec == NULL)
gtk_widget_set_sensitive(w, FALSE);
diff --git a/modules/calendar/e-cal-shell-view-private.c b/modules/calendar/e-cal-shell-view-private.c
index 4aa9d00..46cb825 100644
--- a/modules/calendar/e-cal-shell-view-private.c
+++ b/modules/calendar/e-cal-shell-view-private.c
@@ -851,8 +851,8 @@ e_cal_shell_view_update_sidebar (ECalShellView *cal_shell_view)
struct tm start_tm, end_tm;
struct icaltimetype start_tt, end_tt;
icaltimezone *timezone;
- gchar buffer[512];
- gchar end_buffer[512];
+ gchar buffer[512] = { 0 };
+ gchar end_buffer[512] = { 0 };
g_return_if_fail (E_IS_CAL_SHELL_VIEW (cal_shell_view));
@@ -868,8 +868,10 @@ e_cal_shell_view_update_sidebar (ECalShellView *cal_shell_view)
view_type = gnome_calendar_get_view (calendar);
calendar_view = gnome_calendar_get_calendar_view (calendar, view_type);
- e_calendar_view_get_visible_time_range (
- calendar_view, &start_time, &end_time);
+ if (!e_calendar_view_get_visible_time_range (calendar_view, &start_time, &end_time)) {
+ e_shell_sidebar_set_secondary_text (shell_sidebar, "");
+ return;
+ }
start_tt = icaltime_from_timet_with_zone (start_time, FALSE, timezone);
start_tm.tm_year = start_tt.year - 1900;
diff --git a/plugins/templates/templates.c b/plugins/templates/templates.c
index e562685..1ed02dd 100644
--- a/plugins/templates/templates.c
+++ b/plugins/templates/templates.c
@@ -746,6 +746,7 @@ update_actions_cb (EShellView *shell_view)
&action_count, merge_id, folder_info,
folder, uids->pdata[0]);
+ camel_store_free_folder_info (store, folder_info);
exit:
em_utils_uids_free (uids);
}
diff --git a/shell/e-shell-settings.c b/shell/e-shell-settings.c
index 21cc855..ac25d1f 100644
--- a/shell/e-shell-settings.c
+++ b/shell/e-shell-settings.c
@@ -100,6 +100,8 @@ shell_settings_pspec_for_key (const gchar *property_name,
/* We'll fail in the next switch statement. */
break;
}
+ } else {
+ default_value = gconf_value_copy (default_value);
}
switch (value_type) {
@@ -151,6 +153,7 @@ shell_settings_pspec_for_key (const gchar *property_name,
}
gconf_value_free (default_value);
+ gconf_schema_free (schema);
return pspec;
diff --git a/smime/gui/certificate-manager.c b/smime/gui/certificate-manager.c
index f3a175c..505ffaf 100644
--- a/smime/gui/certificate-manager.c
+++ b/smime/gui/certificate-manager.c
@@ -959,14 +959,18 @@ load_certs (CertificateManagerData *cfm,
for (node = CERT_LIST_HEAD(certList);
!CERT_LIST_END(node, certList);
node = CERT_LIST_NEXT(node)) {
- ECert *cert = e_cert_new ((CERTCertificate*)node->cert);
+ ECert *cert = e_cert_new (CERT_DupCertificate ((CERTCertificate*)node->cert));
ECertType ct = e_cert_get_cert_type (cert);
/* show everything else in a contact tab */
if (ct == type || (type == E_CERT_CONTACT && ct != E_CERT_CA && ct != E_CERT_USER)) {
add_cert (cfm, cert);
+ } else {
+ g_object_unref (cert);
}
}
+
+ CERT_DestroyCertList (certList);
}
static void
diff --git a/smime/lib/e-cert-db.c b/smime/lib/e-cert-db.c
index fc976bf..c21d071 100644
--- a/smime/lib/e-cert-db.c
+++ b/smime/lib/e-cert-db.c
@@ -513,18 +513,21 @@ e_cert_db_find_cert_by_email_address (ECertDB *certdb,
if (SECSuccess != CERT_FilterCertListByUsage(certlist, certUsageEmailRecipient, PR_FALSE)) {
/* XXX gerror */
CERT_DestroyCertificate(any_cert);
- /* XXX free certlist? */
+ CERT_DestroyCertList (certlist);
return NULL;
}
if (CERT_LIST_END(CERT_LIST_HEAD(certlist), certlist)) {
/* XXX gerror */
CERT_DestroyCertificate(any_cert);
- /* XXX free certlist? */
+ CERT_DestroyCertList (certlist);
return NULL;
}
- cert = e_cert_new (CERT_LIST_HEAD(certlist)->cert);
+ cert = e_cert_new (CERT_DupCertificate (CERT_LIST_HEAD(certlist)->cert));
+
+ CERT_DestroyCertList (certlist);
+ CERT_DestroyCertificate (any_cert);
return cert;
}
diff --git a/smime/lib/e-cert.c b/smime/lib/e-cert.c
index 2591678..db41048 100644
--- a/smime/lib/e-cert.c
+++ b/smime/lib/e-cert.c
@@ -140,6 +140,11 @@ e_cert_dispose (GObject *object)
}
}
+ if (ec->priv->cert) {
+ CERT_DestroyCertificate (ec->priv->cert);
+ ec->priv->cert = NULL;
+ }
+
g_free (ec->priv);
ec->priv = NULL;
@@ -257,6 +262,7 @@ e_cert_new (CERTCertificate *cert)
{
ECert *ecert = E_CERT (g_object_new (E_TYPE_CERT, NULL));
+ /* ECert owns a reference to the 'cert', which will be freed on ECert finalize */
ecert->priv->cert = cert;
e_cert_populate (ecert);
@@ -468,6 +474,8 @@ e_cert_get_chain (ECert *ecert)
next_cert = CERT_FindCertIssuer (cert, PR_Now(), certUsageSSLClient);
if (!next_cert)
break;
+
+ /* next_cert has a reference already */
ecert = e_cert_new (next_cert);
}
@@ -477,14 +485,19 @@ e_cert_get_chain (ECert *ecert)
ECert *
e_cert_get_ca_cert(ECert *ecert)
{
- CERTCertificate *cert, *next = e_cert_get_internal_cert(ecert);
+ CERTCertificate *cert, *next = e_cert_get_internal_cert(ecert), *internal;
+ cert = next;
+ internal = cert;
do {
+ if (cert != next && cert != internal)
+ CERT_DestroyCertificate (cert);
+
cert = next;
next = CERT_FindCertIssuer (cert, PR_Now(), certUsageAnyCA);
} while (next && next != cert);
- if (cert == e_cert_get_internal_cert(ecert))
+ if (cert == internal)
return g_object_ref(ecert);
else
return e_cert_new(cert);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]