Handle error if REGCOMP in pager fails when resizing.
authorKevin McCarthy <kevin@8t8.us>
Sun, 6 Aug 2017 17:22:45 +0000 (10:22 -0700)
committerKevin McCarthy <kevin@8t8.us>
Sun, 6 Aug 2017 17:22:45 +0000 (10:22 -0700)
Thanks to JiaZhouyang for finding this issue and supplying the original patch.

pager.c

diff --git a/pager.c b/pager.c
index f83331468a4a304be4e5648c9cbe730cf65e342e..34b9c1fe84c431564e52dc1e4badf3df7df5131d 100644 (file)
--- a/pager.c
+++ b/pager.c
@@ -1630,7 +1630,7 @@ typedef struct
 static void pager_menu_redraw (MUTTMENU *pager_menu)
 {
   pager_redraw_data_t *rd = pager_menu->redraw_data;
-  int i, j;
+  int i, j, err;
   char buffer[LONG_STRING];
 
   if (!rd)
@@ -1697,10 +1697,18 @@ static void pager_menu_redraw (MUTTMENU *pager_menu)
     {
       if ((rd->SearchCompiled = Resize->SearchCompiled))
       {
-        REGCOMP
-          (&rd->SearchRE, rd->searchbuf, REG_NEWLINE | mutt_which_case (rd->searchbuf));
-        rd->SearchFlag = MUTT_SEARCH;
-        rd->SearchBack = Resize->SearchBack;
+        if ((err = REGCOMP (&rd->SearchRE, rd->searchbuf,
+                            REG_NEWLINE | mutt_which_case (rd->searchbuf))) != 0)
+        {
+          regerror (err, &rd->SearchRE, buffer, sizeof (buffer));
+          mutt_error ("%s", buffer);
+          rd->SearchCompiled = 0;
+        }
+        else
+        {
+          rd->SearchFlag = MUTT_SEARCH;
+          rd->SearchBack = Resize->SearchBack;
+        }
       }
       rd->lines = Resize->line;
       pager_menu->redraw |= REDRAW_FLOW;