changeset: 6738:69bbe4da959f user: Anton Lindqvist <anton.lindqv...@gmail.com> date: Tue Jul 19 18:56:13 2016 -0700 link: http://dev.mutt.org/hg/mutt/rev/69bbe4da959f
Fix arithmetic exception due to menu->pagelen being negative. Resizing the terminal window down to two lines when in an empty mailbox causes mutt to crash due to division by zero since menu->max equals 0 and menu->pagelen < 0 in status.c:205. Fixing the problem at this specific line felt wrong since I did notice menu->pagelen being negative. The pagelen is inherited from the rows calculation in mutt_reflow_windows. Since the number of lines can potentially be smaller than the accumulated number of rows acquired by the status, help and message window, make sure the calculation does not turn negative. diffs (14 lines): diff -r f1d5a884ffed -r 69bbe4da959f curs_lib.c --- a/curs_lib.c Sun Jul 17 19:31:16 2016 -0700 +++ b/curs_lib.c Tue Jul 19 18:56:13 2016 -0700 @@ -531,8 +531,8 @@ MuttMessageWindow->row_offset = LINES - 1; memcpy (MuttIndexWindow, MuttStatusWindow, sizeof (mutt_window_t)); - MuttIndexWindow->rows = LINES - MuttStatusWindow->rows - MuttHelpWindow->rows - - MuttMessageWindow->rows; + MuttIndexWindow->rows = MAX(LINES - MuttStatusWindow->rows - + MuttHelpWindow->rows - MuttMessageWindow->rows, 0); MuttIndexWindow->row_offset = option (OPTSTATUSONTOP) ? MuttStatusWindow->rows : MuttHelpWindow->rows;