commit 1e30bfc631ee26191a0b4e9edc8bde63a0d7fa99
parent 2c8ed95f7080187c10adb816d4d5d60fcd355fd4
Author: Colin Leroy <colin@colino.net>
Date: Mon, 28 Apr 2014 12:28:42 +0200
Fix most of the leaks referenced in bug #3155
Diffstat:
16 files changed, 92 insertions(+), 91 deletions(-)
diff --git a/src/compose.c b/src/compose.c
@@ -5348,6 +5348,8 @@ static gint compose_redirect_write_headers(Compose *compose, FILE *fp)
}
generate_msgid(buf, sizeof(buf), addr);
err |= (fprintf(fp, "Resent-Message-ID: <%s>\n", buf) < 0);
+ if (compose->msgid)
+ g_free(compose->msgid);
compose->msgid = g_strdup(buf);
} else {
compose->msgid = NULL;
@@ -6424,6 +6426,8 @@ static gchar *compose_get_header(Compose *compose)
}
generate_msgid(buf, sizeof(buf), addr);
g_string_append_printf(header, "Message-ID: <%s>\n", buf);
+ if (compose->msgid)
+ g_free(compose->msgid);
compose->msgid = g_strdup(buf);
} else {
compose->msgid = NULL;
diff --git a/src/folder.c b/src/folder.c
@@ -3783,17 +3783,18 @@ gint folder_item_remove_msgs(FolderItem *item, GSList *msglist)
real_list,
NULL);
}
- while (ret == 0 && real_list != NULL) {
- MsgInfo *msginfo = (MsgInfo *)real_list->data;
+ cur = real_list;
+ while (ret == 0 && cur != NULL) {
+ MsgInfo *msginfo = (MsgInfo *)cur->data;
if (msginfo && MSG_IS_LOCKED(msginfo->flags)) {
- real_list = real_list->next;
+ cur = cur->next;
continue;
}
if (!item->folder->klass->remove_msgs)
ret = folder_item_remove_msg(item, msginfo->msgnum);
if (ret != 0) break;
msgcache_remove_msg(item->cache, msginfo->msgnum);
- real_list = real_list->next;
+ cur = cur->next;
}
g_slist_free(real_list);
folder_item_scan_full(item, FALSE);
@@ -4261,56 +4262,40 @@ static gchar * folder_item_get_tree_identifier(FolderItem * item)
static FolderItem *folder_create_processing_folder(int account_id)
{
- Folder *processing_folder;
+ static Folder *processing_folder = NULL;
FolderItem *processing_folder_item;
- gchar *tmpname;
gchar *processing_folder_item_name = NULL;
processing_folder_item_name = g_strdup_printf("%s-%d", PROCESSING_FOLDER_ITEM, account_id);
- if ((processing_folder = folder_find_from_name(TEMP_FOLDER, mh_get_class())) == NULL) {
- gchar *tmppath;
-
- tmppath =
+ if (processing_folder == NULL) {
+ gchar *tmppath =
g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
"tempfolder", NULL);
processing_folder =
folder_new(mh_get_class(), TEMP_FOLDER, tmppath);
g_free(tmppath);
+ tmppath = NULL;
+
+ g_assert(processing_folder != NULL);
+ processing_folder->klass->scan_tree(processing_folder);
}
g_assert(processing_folder != NULL);
- debug_print("tmpparentroot %s\n", LOCAL_FOLDER(processing_folder)->rootpath);
- /* FIXME: [W32] The code below does not correctly merge
- relative filenames; there should be a function to handle
- this. */
- if (!is_relative_filename(LOCAL_FOLDER(processing_folder)->rootpath))
- tmpname = g_strconcat(LOCAL_FOLDER(processing_folder)->rootpath,
- G_DIR_SEPARATOR_S,
- processing_folder_item_name,
- NULL);
- else
- tmpname = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S,
- LOCAL_FOLDER(processing_folder)->rootpath,
- G_DIR_SEPARATOR_S,
- processing_folder_item_name,
- NULL);
-
- if (!is_dir_exist(tmpname)) {
- debug_print("*TMP* creating %s\n", tmpname);
+ processing_folder_item = folder_find_child_item_by_name(FOLDER_ITEM(processing_folder->node->data),
+ processing_folder_item_name);
+ if (processing_folder_item) {
+ debug_print("*TMP* already created %s\n", folder_item_get_path(processing_folder_item));
+ } else {
processing_folder_item = processing_folder->klass->create_folder(processing_folder,
processing_folder->node->data,
processing_folder_item_name);
- } else {
- debug_print("*TMP* already created\n");
- processing_folder_item = folder_item_new(processing_folder, processing_folder_item_name, processing_folder_item_name);
- g_assert(processing_folder_item);
- folder_item_append(processing_folder->node->data, processing_folder_item);
- }
+ folder_item_append(FOLDER_ITEM(processing_folder->node->data), processing_folder_item);
+ debug_print("*TMP* creating %s\n", folder_item_get_path(processing_folder_item));
+ }
g_free(processing_folder_item_name);
g_assert(processing_folder_item != NULL);
- g_free(tmpname);
return(processing_folder_item);
}
diff --git a/src/folderview.c b/src/folderview.c
@@ -1613,6 +1613,7 @@ static void folderview_update_node(FolderView *folderview, GtkCMCTreeNode *node)
break;
}
}
+ procmsg_msg_list_free(list);
} else {
/* if unread messages exist, print with bold font */
use_bold = (item->unread_msgs > 0|| item->new_msgs > 0)
diff --git a/src/gtk/combobox.c b/src/gtk/combobox.c
@@ -125,7 +125,10 @@ static gboolean _select_by_text_func(GtkTreeModel *model, GtkTreePath *path,
gtk_tree_model_get (GTK_TREE_MODEL(model), iter, 0, &curdata, -1);
if (!g_utf8_collate(data, curdata)) {
gtk_combo_box_set_active_iter(combobox, iter);
+ g_free(curdata);
return TRUE;
+ } else {
+ g_free(curdata);
}
return FALSE;
diff --git a/src/gtk/gtkcmoptionmenu.c b/src/gtk/gtkcmoptionmenu.c
@@ -861,7 +861,7 @@ static void
gtk_cmoption_menu_calc_size (GtkCMOptionMenu *option_menu)
{
GtkWidget *child;
- GList *children;
+ GList *children, *walk;
GtkRequisition child_requisition;
gint old_width = option_menu->width;
gint old_height = option_menu->height;
@@ -874,10 +874,11 @@ gtk_cmoption_menu_calc_size (GtkCMOptionMenu *option_menu)
if (option_menu->menu)
{
children = gtk_container_get_children (GTK_CONTAINER (GTK_MENU_SHELL (option_menu->menu)));
- while (children)
+ walk = children;
+ while (walk)
{
- child = children->data;
- children = children->next;
+ child = walk->data;
+ walk = walk->next;
if (gtk_widget_get_visible (child))
{
diff --git a/src/gtk/gtkutils.c b/src/gtk/gtkutils.c
@@ -1289,6 +1289,8 @@ static gboolean _combobox_separator_func(GtkTreeModel *model,
if( txt == NULL )
return TRUE;
+
+ g_free(txt);
return FALSE;
}
diff --git a/src/gtk/inputdialog.c b/src/gtk/inputdialog.c
@@ -372,8 +372,6 @@ static void input_dialog_create(gboolean is_password)
remember_checkbtn = gtk_check_button_new_with_label(_("Remember this"));
gtk_box_pack_start(GTK_BOX(vbox), remember_checkbtn, FALSE, FALSE, 0);
- hbox = gtk_hbox_new(TRUE, 0);
-
gtkut_stock_button_set_create(&confirm_area,
&cancel_button, GTK_STOCK_CANCEL,
&ok_button, GTK_STOCK_OK,
diff --git a/src/gtk/menu.c b/src/gtk/menu.c
@@ -218,7 +218,7 @@ gint menu_find_option_menu_index(GtkCMOptionMenu *optmenu, gpointer data,
gpointer menu_data;
GList *children;
GList *cur;
- gint n;
+ gint n, found = -1;
menu = gtk_cmoption_menu_get_menu(optmenu);
children = gtk_container_get_children(GTK_CONTAINER(GTK_MENU_SHELL(menu)));
@@ -229,14 +229,18 @@ gint menu_find_option_menu_index(GtkCMOptionMenu *optmenu, gpointer data,
menu_data = g_object_get_data(G_OBJECT(menuitem),
MENU_VAL_ID);
if (func) {
- if (func(menu_data, data) == 0)
- return n;
- } else if (menu_data == data)
- return n;
+ if (func(menu_data, data) == 0) {
+ found = n;
+ break;
+ }
+ } else if (menu_data == data) {
+ found = n;
+ break;
+ }
}
g_list_free(children);
- return -1;
+ return found;
}
#endif
diff --git a/src/gtk/quicksearch.c b/src/gtk/quicksearch.c
@@ -1075,25 +1075,23 @@ void quicksearch_set_search_strings(QuickSearch *quicksearch)
g_list_append(
quicksearch->normal_search_strings,
g_strdup(strings->data));
- g_free(newstr);
- continue;
- }
-
- matcher_list = matcher_parser_get_cond(newstr, FALSE);
- g_free(newstr);
+ } else {
+ matcher_list = matcher_parser_get_cond(newstr, FALSE);
- if (matcher_list) {
- quicksearch->extended_search_strings =
- g_list_prepend(
- quicksearch->extended_search_strings,
- g_strdup(strings->data));
- matcherlist_free(matcher_list);
- } else
- quicksearch->normal_search_strings =
- g_list_prepend(
- quicksearch->normal_search_strings,
- g_strdup(strings->data));
+ if (matcher_list) {
+ quicksearch->extended_search_strings =
+ g_list_prepend(
+ quicksearch->extended_search_strings,
+ g_strdup(strings->data));
+ matcherlist_free(matcher_list);
+ } else
+ quicksearch->normal_search_strings =
+ g_list_prepend(
+ quicksearch->normal_search_strings,
+ g_strdup(strings->data));
+ }
}
+ g_free(newstr);
} while ((strings = g_list_next(strings)) != NULL);
diff --git a/src/imap.c b/src/imap.c
@@ -769,6 +769,8 @@ static void imap_folder_destroy(Folder *folder)
while (imap_folder_get_refcnt(folder) > 0)
gtk_main_iteration();
+ g_free(IMAP_FOLDER(folder)->search_charset);
+
folder_remote_folder_destroy(REMOTE_FOLDER(folder));
imap_done(folder);
}
@@ -1579,8 +1581,10 @@ static gboolean imap_is_msg_fully_cached(Folder *folder, FolderItem *item, gint
return TRUE;
}
path = folder_item_get_path(item);
- if (!is_dir_exist(path))
+ if (!is_dir_exist(path)) {
+ g_free(path);
return FALSE;
+ }
filename = g_strconcat(path, G_DIR_SEPARATOR_S, itos(uid), NULL);
g_free(path);
@@ -2351,7 +2355,10 @@ static gint search_msgs (Folder *folder,
*msgs = g_slist_prepend(*msgs, GUINT_TO_POINTER(((MsgInfo*) cur->data)->msgnum));
count++;
}
+ procmsg_msg_list_free(list);
+
*msgs = g_slist_reverse(*msgs);
+
return count;
}
@@ -3499,12 +3506,7 @@ static void *imap_get_uncached_messages_thread(void *data)
main_window_reflect_tags_changes(mainwindow_get_mainwindow());
}
- for (cur = seq_list; cur != NULL; cur = g_slist_next(cur)) {
- struct mailimap_set * imapset;
-
- imapset = cur->data;
- mailimap_set_free(imapset);
- }
+ imap_lep_set_free(seq_list);
session_set_access_time(SESSION(session));
stuff->done = TRUE;
diff --git a/src/main.c b/src/main.c
@@ -643,6 +643,8 @@ static void sc_session_manager_connect(MainWindow *mainwin)
vals[0].length = strlen(g_get_user_name()?g_get_user_name():"");
vals[0].value = g_strdup(g_get_user_name()?g_get_user_name():"");
sc_client_set_value (mainwin, SmUserID, SmARRAY8, 1, vals);
+
+ g_free(vals);
}
}
}
@@ -2132,7 +2134,7 @@ gboolean claws_is_starting(void)
gchar *claws_get_socket_name(void)
{
static gchar *filename = NULL;
- const gchar *socket_dir = NULL;
+ gchar *socket_dir = NULL;
gchar md5sum[33];
if (filename == NULL) {
diff --git a/src/mainwindow.c b/src/mainwindow.c
@@ -1145,6 +1145,7 @@ void mainwin_accel_changed_cb (GtkAccelGroup *accelgroup, guint keyval, GdkModif
g_free(new_accel);
}
}
+ g_list_free(closures);
}
static void mainwindow_colorlabel_menu_create(MainWindow *mainwin, gboolean refresh)
diff --git a/src/mimeview.c b/src/mimeview.c
@@ -2535,19 +2535,22 @@ static void icon_list_append_icon (MimeView *mimeview, MimeInfo *mimeinfo)
to_human_readable((goffset)mimeinfo->length), NULL);
g_free(content_type);
if (desc && *desc) {
- gchar *tmp = NULL;
+ gchar *tmp = NULL, *escaped = NULL;
if (!g_utf8_validate(desc, -1, NULL)) {
tmp = conv_filename_to_utf8(desc);
} else {
tmp = g_strdup(desc);
}
+ escaped = g_markup_escape_text(tmp,-1);
+
tiptmp = g_strconcat(tip, "\n<b>",
prefs_common.attach_desc && mimeinfo->description ?
_("Description:") : _("Filename:"),
- " </b>", g_markup_escape_text(tmp,-1), NULL);
+ " </b>", escaped, NULL);
g_free(tip);
tip = tiptmp;
g_free(tmp);
+ g_free(escaped);
}
if (sigshort && *sigshort) {
tiptmp = g_strjoin("\n", tip, g_markup_escape_text(sigshort, -1), NULL);
@@ -2649,10 +2652,10 @@ static void icon_list_create(MimeView *mimeview, MimeInfo *mimeinfo)
static void icon_list_toggle_by_mime_info (MimeView *mimeview,
MimeInfo *mimeinfo)
{
- GList *child;
+ GList *children, *child;
- child = gtk_container_get_children(GTK_CONTAINER(mimeview->icon_vbox));
- for (; child != NULL; child = g_list_next(child)) {
+ children = gtk_container_get_children(GTK_CONTAINER(mimeview->icon_vbox));
+ for (child = children; child != NULL; child = g_list_next(child)) {
if (!GTK_IS_EVENT_BOX(child->data))
continue;
if(g_object_get_data(G_OBJECT(child->data),
@@ -2670,6 +2673,7 @@ static void icon_list_toggle_by_mime_info (MimeView *mimeview,
gtk_widget_queue_draw(icon);
}
}
+ g_list_free(children);
}
static void ctree_size_allocate_cb(GtkWidget *widget, GtkAllocation *allocation,
diff --git a/src/prefs_account.c b/src/prefs_account.c
@@ -920,19 +920,6 @@ static void prefs_account_edit_custom_header (void);
* system choice. */
static void privacy_system_activated(GtkWidget *combobox)
{
- const gchar *system_id;
- gint privacy_enabled_int;
- GtkTreeIter iter;
- GtkListStore *menu = GTK_LIST_STORE(gtk_combo_box_get_model(
- GTK_COMBO_BOX(combobox)));
-
- gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combobox), &iter);
-
- gtk_tree_model_get(GTK_TREE_MODEL(menu), &iter,
- COMBOBOX_PRIVACY_PLUGIN_ID, &system_id,
- COMBOBOX_DATA, &privacy_enabled_int,
- -1);
-
gtk_widget_set_sensitive (privacy_page.save_clear_text_checkbtn,
!gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(privacy_page.encrypt_to_self_checkbtn)));
@@ -2657,6 +2644,7 @@ static void advanced_create_widget_func(PrefsPage * _page,
GtkWidget *trash_folder_entry;
GtkWidget *imap_use_trash_checkbtn;
GtkSizeGroup *size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
+
#define PACK_HBOX(hbox) \
{ \
hbox = gtk_hbox_new (FALSE, 8); \
@@ -2845,6 +2833,8 @@ static void advanced_create_widget_func(PrefsPage * _page,
page->vbox = vbox1;
page->page.widget = vbox1;
+
+ g_object_unref(G_OBJECT(size_group));
}
static gint prefs_basic_apply(void)
diff --git a/src/prefs_themes.c b/src/prefs_themes.c
@@ -406,7 +406,7 @@ static void prefs_themes_free_names(ThemesData *tdata)
names = g_list_next(names);
}
- g_list_free(names);
+ g_list_free(tdata->names);
tdata->names = NULL;
}
diff --git a/src/quote_fmt.c b/src/quote_fmt.c
@@ -257,6 +257,8 @@ void quotefmt_create_new_msg_fmt_widgets(GtkWindow *parent_window,
*override_from_format = entry_from;
*edit_subject_format = entry_subject;
*edit_body_format = text_format;
+
+ g_object_unref(G_OBJECT(size_group));
}
void quotefmt_create_reply_fmt_widgets(GtkWindow *parent_window,
@@ -385,6 +387,8 @@ void quotefmt_create_reply_fmt_widgets(GtkWindow *parent_window,
if (override_from_format)
*override_from_format = entry_from;
*edit_reply_format = text_quotefmt;
+
+ g_object_unref(G_OBJECT(size_group));
}
void quotefmt_create_forward_fmt_widgets(GtkWindow *parent_window,
@@ -515,6 +519,8 @@ void quotefmt_create_forward_fmt_widgets(GtkWindow *parent_window,
if (override_from_format)
*override_from_format = entry_from;
*edit_fw_format = text_fw_quotefmt;
+
+ g_object_unref(G_OBJECT(size_group));
}
void quotefmt_add_info_button(GtkWindow *parent_window, GtkWidget *parent_box)