# HG changeset patch # User Anton Lindqvist <anton.lindqv...@gmail.com> # Date 1468939386 -7200 # Tue Jul 19 16:43:06 2016 +0200 # Node ID 749e5e580f0fa0d9f3ec681a2abca35262cfa3f3 # Parent f1d5a884ffed196c4adc72ad7c03c5229acc889c Fix arithmetic exception
Resizing the terminal window running mutt down to two lines causes mutt to crash due to division by zero since menu->max equals 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. This fixes the crash and is hopefully the right place to solve the problem at. If not, I apologize for the noise and any pointers would be much appreciated. diff -r f1d5a884ffed -r 749e5e580f0f curs_lib.c --- a/curs_lib.c Sun Jul 17 19:31:16 2016 -0700 +++ b/curs_lib.c Tue Jul 19 16:43:06 2016 +0200 @@ -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;