Patch 8.2.1787
Problem:    Crash with 'incsearch' and very long line.
Solution:   Check whether regprog becomes NULL. (closes #7063)
Files:      src/search.c, src/testdir/test_search.vim


*** ../vim-8.2.1786/src/search.c        2020-09-22 22:08:28.559532201 +0200
--- src/search.c        2020-10-02 20:35:19.997427200 +0200
***************
*** 759,764 ****
--- 759,767 ----
                                             NULL, NULL
  #endif
                                                      );
+               // vim_regexec_multi() may clear "regprog"
+               if (regmatch.regprog == NULL)
+                   break;
                // Abort searching on an error (e.g., out of stack).
                if (called_emsg > called_emsg_before
  #ifdef FEAT_RELTIME
***************
*** 858,863 ****
--- 861,869 ----
                                match_ok = FALSE;
                                break;
                            }
+                           // vim_regexec_multi() may clear "regprog"
+                           if (regmatch.regprog == NULL)
+                               break;
                            matchpos = regmatch.startpos[0];
                            endpos = regmatch.endpos[0];
  # ifdef FEAT_EVAL
***************
*** 972,977 ****
--- 978,986 ----
  #endif
                                break;
                            }
+                           // vim_regexec_multi() may clear "regprog"
+                           if (regmatch.regprog == NULL)
+                               break;
  
                            // Need to get the line pointer again, a
                            // multi-line search may have made it invalid.
***************
*** 1065,1070 ****
--- 1074,1083 ----
            }
            at_first_line = FALSE;
  
+           // vim_regexec_multi() may clear "regprog"
+           if (regmatch.regprog == NULL)
+               break;
+ 
            /*
             * Stop the search if wrapscan isn't set, "stop_lnum" is
             * specified, after an interrupt, after a match and after looping
***************
*** 2911,2917 ****
                               pos.lnum, regmatch.startpos[0].col, NULL, NULL);
            if (nmatched != 0)
                break;
!       } while (direction == FORWARD ? regmatch.startpos[0].col < pos.col
                                      : regmatch.startpos[0].col > pos.col);
  
        if (called_emsg == called_emsg_before)
--- 2924,2931 ----
                               pos.lnum, regmatch.startpos[0].col, NULL, NULL);
            if (nmatched != 0)
                break;
!       } while (regmatch.regprog != NULL
!               && direction == FORWARD ? regmatch.startpos[0].col < pos.col
                                      : regmatch.startpos[0].col > pos.col);
  
        if (called_emsg == called_emsg_before)
*** ../vim-8.2.1786/src/testdir/test_search.vim 2020-09-26 22:39:18.427725844 
+0200
--- src/testdir/test_search.vim 2020-10-02 20:32:03.537989616 +0200
***************
*** 964,969 ****
--- 964,983 ----
    call Incsearch_cleanup()
  endfunc
  
+ func Test_incsearch_substitute_long_line()
+   new
+   call test_override("char_avail", 1)
+   set incsearch
+ 
+   call repeat('x', 100000)->setline(1)
+   call feedkeys(':s/\%c', 'xt')
+   redraw
+   call feedkeys("\<Esc>", 'xt')
+ 
+   call Incsearch_cleanup()
+   bwipe!
+ endfunc
+ 
  " Similar to Test_incsearch_substitute() but with a screendump halfway.
  func Test_incsearch_substitute_dump()
    CheckOption incsearch
*** ../vim-8.2.1786/src/version.c       2020-10-02 18:48:02.846263669 +0200
--- src/version.c       2020-10-02 20:26:54.078875479 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     1787,
  /**/

-- 
How To Keep A Healthy Level Of Insanity:
12. Sing along at the opera.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202010021836.092IaWZY1609646%40masaka.moolenaar.net.

Raspunde prin e-mail lui