Fix segfault invoking function from python code
authorRicardo Mones <ricardo@mones.org>
Tue, 16 Mar 2021 23:01:55 +0000 (00:01 +0100)
committerRicardo Mones <ricardo@mones.org>
Tue, 16 Mar 2021 23:01:55 +0000 (00:01 +0100)
When using python code is possible to add new menu items invoking module
functions. Since they're added on-the-fly, these items can't be included
in the logic which enables or disables menu entries according UI status.
Hence the functions need checking what's really available instead of
relying on the inability of users to not invoke the funcion through UI.

There's probably more functions which need similar fixes, though, this
one just appeared when trying to convert startup example to python3.

Thread 1 "claws-mail" received signal SIGSEGV, Segmentation fault.
0x0000000000583efa in summary_mark_as_read (summaryview=0xd9dc70) at summaryview.c:4179
4179            if ((summaryview->folder_item->total_msgs == (gint)g_list_length(GTK_CMCLIST(ctree)->selection) &&

src/summaryview.c

index f72bfe1035106393ee5914ed4808b8604bb26ad9..e41bd846c938ee17f7c4566ef98a6effbee7ef4b 100644 (file)
@@ -4176,6 +4176,9 @@ void summary_mark_as_read(SummaryView *summaryview)
        if (summary_is_locked(summaryview))
                return;
 
+       if (!summaryview->folder_item)
+               return;
+
        if ((summaryview->folder_item->total_msgs == (gint)g_list_length(GTK_CMCLIST(ctree)->selection) &&
             summaryview->folder_item->total_msgs > 1) &&
            !summary_mark_all_read_confirm(TRUE))