talons

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

commit 2e626bf179777336beccb385b817465bf64c4a34
parent 2365b058e7ac75afc82e06ad43ead42fdee0c98f
Author: wwp <subscript@free.fr>
Date:   Sun, 26 Sep 2021 19:41:22 +0200

Fix CID 1491116: explicit null dereference,
make sure folder item identifier is set and further allocations are possible when building a path list.

Diffstat:
Msrc/summaryview.c | 32++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/src/summaryview.c b/src/summaryview.c @@ -7607,24 +7607,28 @@ static void summary_drag_data_get(GtkWidget *widget, path_list = folder_item_get_identifier(msginfo->folder); } - for (cur = GTK_CMCLIST(ctree)->selection; - cur != NULL && cur->data != NULL; cur = cur->next) { - gchar *tmp; + if (path_list != NULL) { + for (cur = GTK_CMCLIST(ctree)->selection; + cur != NULL && cur->data != NULL && path_list != NULL; cur = cur->next) { + gchar *tmp; - msginfo = gtk_cmctree_node_get_row_data(ctree, GTK_CMCTREE_NODE(cur->data)); - if(!msginfo) - continue; - tmp = path_list; - path_list = g_strconcat(path_list, "\n", (msginfo->msgid ? msginfo->msgid : "unknown"), NULL); - g_free(tmp); - } + msginfo = gtk_cmctree_node_get_row_data(ctree, GTK_CMCTREE_NODE(cur->data)); + if(!msginfo) + continue; + tmp = path_list; + path_list = g_strconcat(path_list, "\n", (msginfo->msgid ? msginfo->msgid : "unknown"), NULL); + g_free(tmp); + } - if (path_list != NULL) { - gtk_selection_data_set(selection_data, + if (path_list != NULL) { + gtk_selection_data_set(selection_data, gtk_selection_data_get_target(selection_data), 8, path_list, strlen(path_list)); - g_free(path_list); - } + g_free(path_list); + } + } else { + g_warning("summary_drag_data_get: no folder item identifier"); + } } }