talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit de1fd9b0e2b3569cdaae2d6578c526a3f7c1880a
parent db12cf5f4b7e322a38865c50f5229015483cc692
Author: Paul <paul@claws-mail.org>
Date:   Tue, 20 Feb 2024 08:31:03 +0000

fix several USE_AFTER_FREE coverity bugs

CIDs 1491105, 1491164, 1491139, 1491166, 1491168, 1491169, 1491178, 1491232, 1491242, 1492281

Diffstat:
Msrc/addressadd.c | 4++--
Msrc/browseldap.c | 4++--
Msrc/grouplistdialog.c | 4++--
Msrc/gtk/foldersort.c | 6+++---
Msrc/mainwindow.c | 7+++----
Msrc/messageview.c | 4++--
Msrc/plugins/att_remover/att_remover.c | 8+++-----
Msrc/plugins/pdf_viewer/poppler_viewer.c | 4++--
Msrc/plugins/smime/smime.c | 4++--
Msrc/sourcewindow.c | 2+-
Msrc/summaryview.c | 4++--
11 files changed, 24 insertions(+), 27 deletions(-)

diff --git a/src/addressadd.c b/src/addressadd.c @@ -1,6 +1,6 @@ /* * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 2001-2022 Match Grun and the Claws Mail team + * Copyright (C) 2001-2024 the Claws Mail team and Match Grun * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -265,8 +265,8 @@ static void addressadd_create( void ) { GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_POINTER); tree_folder = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); - g_object_unref(store); gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store), ADDRADD_COL_NAME, GTK_SORT_ASCENDING); + g_object_unref(store); gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tree_folder), prefs_common.use_stripes_everywhere); gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree_folder), TRUE); gtk_tree_view_set_enable_tree_lines(GTK_TREE_VIEW(tree_folder), FALSE); diff --git a/src/browseldap.c b/src/browseldap.c @@ -1,6 +1,6 @@ /* * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 2003-2022 Match Grun and the Claws Mail team + * Copyright (C) 2003-2024 the Claws Mail team and Match Grun * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -274,7 +274,6 @@ static void browse_create( void ) { -1); view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); - g_object_unref(store); gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), TRUE); gtk_tree_view_set_reorderable(GTK_TREE_VIEW(view), FALSE); sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(view)); @@ -294,6 +293,7 @@ static void browse_create( void ) { gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store), COL_NAME, GTK_SORT_ASCENDING); + g_object_unref(store); gtk_container_add( GTK_CONTAINER(tree_win), view ); diff --git a/src/grouplistdialog.c b/src/grouplistdialog.c @@ -1,6 +1,6 @@ /* * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 1999-2022 the Claws Mail team and Hiroyuki Yamamoto + * Copyright (C) 1999-2024 the Claws Mail team and Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -599,8 +599,8 @@ static gboolean button_press_cb(GtkCMCTree *ctree, GdkEventButton *button, list = g_slist_find_custom(subscribed, ginfo->name, (GCompareFunc)g_ascii_strcasecmp); if (list) { - g_free(list->data); subscribed = g_slist_remove(subscribed, list->data); + g_free(list->data); gtk_cmclist_unselect_row(GTK_CMCLIST(ctree), row, 0); } else { subscribed = g_slist_append(subscribed, g_strdup(ginfo->name)); diff --git a/src/gtk/foldersort.c b/src/gtk/foldersort.c @@ -1,6 +1,6 @@ /* * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 2004-2022 the Claws Mail Team + * Copyright (C) 2004-2024 the Claws Mail Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -289,7 +289,7 @@ void foldersort_open() /* Create the view widget */ folderlist = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); - g_object_unref(store); + gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(folderlist), TRUE); gtk_tree_view_set_reorderable(GTK_TREE_VIEW(folderlist), TRUE); selector = gtk_tree_view_get_selection(GTK_TREE_VIEW(folderlist)); @@ -379,6 +379,6 @@ void foldersort_open() gtk_tree_selection_select_iter(selector, &iter); set_selected(dialog); } - + g_object_unref(store); inc_lock(); } diff --git a/src/mainwindow.c b/src/mainwindow.c @@ -1,6 +1,6 @@ /* * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 1999-2023 the Claws Mail team and Hiroyuki Yamamoto + * Copyright (C) 1999-2024 the Claws Mail team and Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -3849,10 +3849,9 @@ void main_window_destroy_all(void) mainwin->summaryview->mainwin = NULL; mainwin->messageview->mainwin = NULL; - g_free(mainwin->toolbar); - g_free(mainwin); - + g_free(mainwin->toolbar); mainwin_list = g_list_remove(mainwin_list, mainwin); + g_free(mainwin); } g_list_free(mainwin_list); mainwin_list = NULL; diff --git a/src/messageview.c b/src/messageview.c @@ -1,6 +1,6 @@ /* * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 1999-2022 the Claws Mail team and Hiroyuki Yamamoto + * Copyright (C) 1999-2024 the Claws Mail team and Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -2732,8 +2732,8 @@ static void view_source_cb(GtkAction *action, gpointer data) if (!messageview->msginfo) return; srcwin = source_window_create(); - source_window_show_msg(srcwin, messageview->msginfo); source_window_show(srcwin); + source_window_show_msg(srcwin, messageview->msginfo); } static void show_all_header_cb(GtkToggleAction *action, gpointer data) diff --git a/src/plugins/att_remover/att_remover.c b/src/plugins/att_remover/att_remover.c @@ -1,11 +1,9 @@ /* * att_remover -- for Claws Mail - * - * Copyright (C) 2005-2022 Colin Leroy <colin@colino.net> - * and the Claws Mail Team + * Copyright (C) 2005-2024 the Claws Mail Team and Colin Leroy * * Claws Mail is a GTK based, lightweight, and fast e-mail client - * Copyright (C) 1999-2019 Hiroyuki Yamamoto and the Claws Mail Team + * Copyright (C) 1999-2024 the Claws Mail Team and Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -354,11 +352,11 @@ static void remove_attachments_dialog(AttRemover *attremover) G_TYPE_BOOLEAN, -1)); list_view = GTK_TREE_VIEW(gtk_tree_view_new_with_model(model)); - g_object_unref(model); gtk_tree_view_set_rules_hint(list_view, prefs_common_get_prefs()->use_stripes_everywhere); renderer = gtk_cell_renderer_toggle_new(); g_signal_connect(renderer, "toggled", G_CALLBACK(remove_toggled_cb), model); + g_object_unref(model); column = gtk_tree_view_column_new_with_attributes (_("Remove"), renderer, diff --git a/src/plugins/pdf_viewer/poppler_viewer.c b/src/plugins/pdf_viewer/poppler_viewer.c @@ -1,6 +1,6 @@ /* * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 1999-2022 the Claws Mail Team and Salvatore De Paolis + * Copyright (C) 1999-2024 the Claws Mail Team and Salvatore De Paolis * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1853,7 +1853,6 @@ static MimeViewer *pdf_viewer_create(void) G_TYPE_DOUBLE); viewer->index_list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(tree_store)); - g_object_unref(tree_store); renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes(_("Name"), renderer, "text", 0, NULL); @@ -1861,6 +1860,7 @@ static MimeViewer *pdf_viewer_create(void) gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(viewer->index_list), FALSE); viewer->index_model = GTK_TREE_MODEL(tree_store); + g_object_unref(tree_store); gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(viewer->index_list)), GTK_SELECTION_SINGLE); diff --git a/src/plugins/smime/smime.c b/src/plugins/smime/smime.c @@ -1,6 +1,6 @@ /* * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 1999-2021 Colin Leroy and the Claws Mail team + * Copyright (C) 1999-2024 the Claws Mail team and Colin Leroy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1009,7 +1009,7 @@ gboolean smime_encrypt(MimeInfo *mimeinfo, const gchar *encrypt_data) claws_fclose(fp); claws_unlink(tmpfile); } - if (claws_safe_fclose(fp) == EOF) { + if (fp != NULL && claws_safe_fclose(fp) == EOF) { FILE_OP_ERROR(tmpfile, "claws_fclose"); claws_unlink(tmpfile); g_free(tmpfile); diff --git a/src/sourcewindow.c b/src/sourcewindow.c @@ -1,6 +1,6 @@ /* * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 1999-2019 the Claws Mail team and Hiroyuki Yamamoto + * Copyright (C) 1999-2024 the Claws Mail team and Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/summaryview.c b/src/summaryview.c @@ -1,6 +1,6 @@ /* * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 1999-2023 the Claws Mail team and Hiroyuki Yamamoto + * Copyright (C) 1999-2024 the Claws Mail team and Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -3863,8 +3863,8 @@ void summary_view_source(SummaryView * summaryview) srcwin = source_window_create(); msginfo = gtk_cmctree_node_get_row_data(ctree, summaryview->selected); - source_window_show_msg(srcwin, msginfo); source_window_show(srcwin); + source_window_show_msg(srcwin, msginfo); } void summary_reedit(SummaryView *summaryview)