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: neomutt-20160822~80 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fc8a37bcee78d12585ed0600bb18b35dc3ec4964;p=neomutt 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 ef01f0d6f..ed0d10c34 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 ffbb350d7..d696cd581 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);