From: Kevin McCarthy Date: Tue, 12 Jul 2016 01:36:21 +0000 (-0700) Subject: Initialize mutt windows even in batch mode. (closes #3853) X-Git-Tag: mutt-1-7-rel~33 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c00f444a82a53e9a27864a4f44a1c072fb7c3128;p=mutt Initialize mutt windows even in batch mode. (closes #3853) mutt_select_fcc() calls mutt_addr_hook() -> mutt_make_string() which refers to MuttIndexWindow->cols when calling mutt_FormatString(). In batch mode, MuttIndexWindow hasn't been initialized, leading to a segfault. This might be the only overlap, but it seems wiser to just initialize the mutt windows in case there are other references (now or in the future) when processing format strings in batch mode. --- diff --git a/curs_lib.c b/curs_lib.c index ef01f0d6..ed0d10c3 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -496,8 +496,6 @@ void mutt_init_windows () #ifdef USE_SIDEBAR MuttSidebarWindow = safe_calloc (sizeof (mutt_window_t), 1); #endif - - mutt_reflow_windows (); } void mutt_free_windows () diff --git a/main.c b/main.c index ffbb350d..d696cd58 100644 --- a/main.c +++ b/main.c @@ -556,7 +556,7 @@ static void start_curses (void) meta (stdscr, TRUE); #endif init_extended_keys(); - mutt_init_windows (); + mutt_reflow_windows (); } #define MUTT_IGNORE (1<<0) /* -z */ @@ -780,6 +780,10 @@ int main (int argc, char **argv) sendflags = SENDBATCH; } + /* Always create the mutt_windows because batch mode has some shared code + * paths that end up referencing them. */ + mutt_init_windows (); + /* This must come before mutt_init() because curses needs to be started before calling the init_pair() function to set the color scheme. */ if (!option (OPTNOCURSES)) @@ -1158,11 +1162,9 @@ int main (int argc, char **argv) FREE (&tempfile); } + mutt_free_windows (); if (!option (OPTNOCURSES)) - { - mutt_free_windows (); mutt_endwin (NULL); - } if (rv) exit(1);