commit 8dde5e6b4bd5b052ec2bf9bc12d7ca9714143cd5
parent 943c87cd311268d9c9d0766197c2ede061aa58ad
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:
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/src/summaryview.c b/src/summaryview.c
@@ -7639,24 +7639,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");
+ }
}
}