[evolution] Fix memory leaks around gtk_tree_model_get() function
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Fix memory leaks around gtk_tree_model_get() function
- Date: Thu, 31 May 2012 08:45:11 +0000 (UTC)
commit 71924fc48776c642fe8520febc384250cf55973c
Author: Milan Crha <mcrha redhat com>
Date: Thu May 31 10:44:49 2012 +0200
Fix memory leaks around gtk_tree_model_get() function
calendar/alarm-notify/alarm-notify-dialog.c | 4 ++++
mail/e-mail-label-list-store.c | 1 +
mail/e-mail-sidebar.c | 2 ++
mail/em-folder-tree.c | 1 +
modules/mail/em-mailer-prefs.c | 7 +++++++
plugins/attachment-reminder/attachment-reminder.c | 2 ++
plugins/imap-features/imap-headers.c | 2 ++
plugins/templates/templates.c | 12 ++++++++++--
smime/gui/certificate-manager.c | 7 +++++++
widgets/e-timezone-dialog/e-timezone-dialog.c | 12 +++++++-----
widgets/misc/e-contact-map-window.c | 1 +
11 files changed, 44 insertions(+), 7 deletions(-)
---
diff --git a/calendar/alarm-notify/alarm-notify-dialog.c b/calendar/alarm-notify/alarm-notify-dialog.c
index fc37d88..f4bc1f4 100644
--- a/calendar/alarm-notify/alarm-notify-dialog.c
+++ b/calendar/alarm-notify/alarm-notify-dialog.c
@@ -502,6 +502,10 @@ tree_selection_changed_cb (GtkTreeSelection *selection,
gtk_tree_model_get (model, &iter, ALARM_FUNCINFO_COLUMN, &an->cur_funcinfo, -1);
fill_in_labels (an, summary, description, location, occur_start, occur_end);
+
+ g_free (summary);
+ g_free (description);
+ g_free (location);
} else {
gtk_widget_set_sensitive (an->snooze_btn, FALSE);
gtk_widget_set_sensitive (an->edit_btn, FALSE);
diff --git a/mail/e-mail-label-list-store.c b/mail/e-mail-label-list-store.c
index 706aaac..bf64216 100644
--- a/mail/e-mail-label-list-store.c
+++ b/mail/e-mail-label-list-store.c
@@ -247,6 +247,7 @@ labels_model_changed_cb (GtkTreeModel *model,
store->priv->mail_settings, "labels",
(const gchar * const *) array->pdata);
+ g_ptr_array_foreach (array, (GFunc) g_free, NULL);
g_ptr_array_free (array, TRUE);
g_signal_handlers_unblock_by_func (
diff --git a/mail/e-mail-sidebar.c b/mail/e-mail-sidebar.c
index ef2133a..d4aeeb7 100644
--- a/mail/e-mail-sidebar.c
+++ b/mail/e-mail-sidebar.c
@@ -171,6 +171,8 @@ mail_sidebar_selection_changed_cb (GtkTreeSelection *selection,
if (CAMEL_IS_STORE (store) && folder_name != NULL)
uri = e_mail_folder_uri_build (store, folder_name);
+
+ g_free (folder_name);
}
if (uri != NULL)
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c
index d55253e..45d83d4 100644
--- a/mail/em-folder-tree.c
+++ b/mail/em-folder-tree.c
@@ -2294,6 +2294,7 @@ tree_drag_data_received (GtkWidget *widget,
gdk_drag_context_get_selected_action (context) == GDK_ACTION_MOVE)) {
gtk_drag_finish (context, FALSE, FALSE, GDK_CURRENT_TIME);
gtk_tree_path_free (dest_path);
+ g_free (full_name);
return;
}
diff --git a/modules/mail/em-mailer-prefs.c b/modules/mail/em-mailer-prefs.c
index d81656f..cf20b8f 100644
--- a/modules/mail/em-mailer-prefs.c
+++ b/modules/mail/em-mailer-prefs.c
@@ -364,9 +364,12 @@ emmp_header_add_sensitivity (EMMailerPrefs *prefs)
-1);
if (g_ascii_strcasecmp (header_name, entry_contents) == 0) {
gtk_widget_set_sensitive (GTK_WIDGET (prefs->add_header), FALSE);
+ g_free (header_name);
return;
}
+ g_free (header_name);
+
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (prefs->header_list_store), &iter);
}
@@ -388,6 +391,8 @@ emmp_save_headers (EMMailerPrefs *prefs)
gboolean enabled;
gchar *xml;
+ h.name = NULL;
+
gtk_tree_model_get (GTK_TREE_MODEL (prefs->header_list_store), &iter,
HEADER_LIST_HEADER_COLUMN, &h.name,
HEADER_LIST_ENABLED_COLUMN, &enabled,
@@ -397,6 +402,8 @@ emmp_save_headers (EMMailerPrefs *prefs)
if ((xml = e_mail_reader_header_to_xml (&h)))
header_list = g_slist_append (header_list, xml);
+ g_free (h.name);
+
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (prefs->header_list_store), &iter);
}
diff --git a/plugins/attachment-reminder/attachment-reminder.c b/plugins/attachment-reminder/attachment-reminder.c
index 7625945..5f34941 100644
--- a/plugins/attachment-reminder/attachment-reminder.c
+++ b/plugins/attachment-reminder/attachment-reminder.c
@@ -351,6 +351,8 @@ commit_changes (UIData *ui)
/* Check if the keyword is not empty */
if ((keyword) && (g_utf8_strlen (g_strstrip (keyword), -1) > 0))
g_variant_builder_add (&b, "s", keyword);
+ g_free (keyword);
+
valid = gtk_tree_model_iter_next (model, &iter);
}
diff --git a/plugins/imap-features/imap-headers.c b/plugins/imap-features/imap-headers.c
index 3a0917f..56f7e4f 100644
--- a/plugins/imap-features/imap-headers.c
+++ b/plugins/imap-features/imap-headers.c
@@ -168,10 +168,12 @@ epif_add_sensitivity (EPImapFeaturesData *ui)
0, &header_name,
-1);
if (g_ascii_strcasecmp (header_name, entry_contents) == 0) {
+ g_free (header_name);
gtk_widget_set_sensitive (GTK_WIDGET (ui->add_header), FALSE);
return;
}
+ g_free (header_name);
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (ui->store), &iter);
}
diff --git a/plugins/templates/templates.c b/plugins/templates/templates.c
index 7589164..4359af0 100644
--- a/plugins/templates/templates.c
+++ b/plugins/templates/templates.c
@@ -169,8 +169,10 @@ commit_changes (UIData *ui)
gchar *keyword, *value;
gchar *key;
- gtk_tree_model_get (model, &iter, CLUE_KEYWORD_COLUMN, &keyword, -1);
- gtk_tree_model_get (model, &iter, CLUE_VALUE_COLUMN, &value, -1);
+ gtk_tree_model_get (model, &iter,
+ CLUE_KEYWORD_COLUMN, &keyword,
+ CLUE_VALUE_COLUMN, &value,
+ -1);
/* Check if the keyword and value are not empty */
if ((keyword) && (value) && (g_utf8_strlen (g_strstrip (keyword), -1) > 0)
@@ -178,6 +180,10 @@ commit_changes (UIData *ui)
key = g_strdup_printf("%s=%s", keyword, value);
g_variant_builder_add (&b, "s", key);
}
+
+ g_free (keyword);
+ g_free (value);
+
valid = gtk_tree_model_iter_next (model, &iter);
}
@@ -260,6 +266,7 @@ key_cell_edited_callback (GtkCellRendererText *cell,
gtk_tree_model_get (model, &iter, CLUE_VALUE_COLUMN, &value, -1);
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
CLUE_KEYWORD_COLUMN, new_text, CLUE_VALUE_COLUMN, value, -1);
+ g_free (value);
commit_changes (ui);
}
@@ -282,6 +289,7 @@ value_cell_edited_callback (GtkCellRendererText *cell,
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
CLUE_KEYWORD_COLUMN, keyword, CLUE_VALUE_COLUMN, new_text, -1);
+ g_free (keyword);
commit_changes (ui);
}
diff --git a/smime/gui/certificate-manager.c b/smime/gui/certificate-manager.c
index ac42e1d..f8a3a1b 100644
--- a/smime/gui/certificate-manager.c
+++ b/smime/gui/certificate-manager.c
@@ -461,6 +461,9 @@ find_cert_cb (GtkTreeModel *model,
fcd->path = gtk_tree_path_copy (path);
}
+ if (cert)
+ g_object_unref (cert);
+
return fcd->path != NULL;
}
@@ -515,6 +518,7 @@ view_cert (GtkWidget *button,
dialog, "response",
G_CALLBACK (gtk_widget_destroy), NULL);
gtk_widget_show (dialog);
+ g_object_unref (cert);
}
}
}
@@ -569,6 +573,7 @@ edit_cert (GtkWidget *button,
}
gtk_widget_destroy (dialog);
+ g_object_unref (cert);
}
}
}
@@ -671,6 +676,8 @@ delete_cert (GtkWidget *button,
* and added it to the tree */
g_object_unref (cert);
g_object_unref (cert);
+ } else if (cert) {
+ g_object_unref (cert);
}
}
diff --git a/widgets/e-timezone-dialog/e-timezone-dialog.c b/widgets/e-timezone-dialog/e-timezone-dialog.c
index c5ccfd3..58fda69 100644
--- a/widgets/e-timezone-dialog/e-timezone-dialog.c
+++ b/widgets/e-timezone-dialog/e-timezone-dialog.c
@@ -106,7 +106,7 @@ static void on_combo_changed (GtkComboBox *combo,
ETimezoneDialog *etd);
static void timezone_combo_get_active_text (GtkComboBox *combo,
- const gchar **zone_name);
+ gchar **zone_name);
static gboolean timezone_combo_set_active_text (GtkComboBox *combo,
const gchar *zone_name);
@@ -754,7 +754,7 @@ on_combo_changed (GtkComboBox *combo_box,
ETimezoneDialog *etd)
{
ETimezoneDialogPrivate *priv;
- const gchar *new_zone_name;
+ gchar *new_zone_name;
icalarray *zones;
icaltimezone *map_zone = NULL;
gchar *location;
@@ -765,7 +765,7 @@ on_combo_changed (GtkComboBox *combo_box,
timezone_combo_get_active_text (
GTK_COMBO_BOX (priv->timezone_combo), &new_zone_name);
- if (!*new_zone_name)
+ if (!new_zone_name || !*new_zone_name)
priv->zone = NULL;
else if (!g_utf8_collate (new_zone_name, _("UTC")))
priv->zone = icaltimezone_get_utc_timezone ();
@@ -784,11 +784,13 @@ on_combo_changed (GtkComboBox *combo_box,
}
set_map_timezone (etd, map_zone);
+
+ g_free (new_zone_name);
}
static void
timezone_combo_get_active_text (GtkComboBox *combo,
- const gchar **zone_name)
+ gchar **zone_name)
{
GtkTreeModel *list_store;
GtkTreeIter iter;
@@ -799,7 +801,7 @@ timezone_combo_get_active_text (GtkComboBox *combo,
if (gtk_combo_box_get_active_iter (combo, &iter))
gtk_tree_model_get (list_store, &iter, 0, zone_name, -1);
else
- *zone_name = "";
+ *zone_name = NULL;
}
static gboolean
diff --git a/widgets/misc/e-contact-map-window.c b/widgets/misc/e-contact-map-window.c
index 38fe56c..4661024 100644
--- a/widgets/misc/e-contact-map-window.c
+++ b/widgets/misc/e-contact-map-window.c
@@ -196,6 +196,7 @@ map_contact_removed_cb (EContactMap *map,
gchar *name_str;
gtk_tree_model_get (model, &iter, 0, &name_str, -1);
if (g_ascii_strcasecmp (name_str, name) == 0) {
+ g_free (name_str);
gtk_list_store_remove (priv->completion_model, &iter);
break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]