Patch 8.2.4687
Problem:    "vimgrep /\%v/ *" may cause a crash.
Solution:   When compiling the pattern with the old engine fails, restore the
            regprog of the new engine instead of leaving it NULL.
            (closes #10079)
Files:      src/regexp.c


*** ../vim-8.2.4686/src/regexp.c        2022-02-16 19:24:03.626162408 +0000
--- src/regexp.c        2022-04-04 17:48:43.869248025 +0100
***************
*** 2874,2882 ****
        char_u *pat = vim_strsave(((nfa_regprog_T *)rmp->regprog)->pattern);
  
        p_re = BACKTRACKING_ENGINE;
-       vim_regfree(rmp->regprog);
        if (pat != NULL)
        {
  #ifdef FEAT_EVAL
            report_re_switch(pat);
  #endif
--- 2874,2883 ----
        char_u *pat = vim_strsave(((nfa_regprog_T *)rmp->regprog)->pattern);
  
        p_re = BACKTRACKING_ENGINE;
        if (pat != NULL)
        {
+           regprog_T *prev_prog = rmp->regprog;
+ 
  #ifdef FEAT_EVAL
            report_re_switch(pat);
  #endif
***************
*** 2889,2897 ****
  #ifdef FEAT_SYN_HL
            reg_do_extmatch = 0;
  #endif
! 
!           if (rmp->regprog != NULL)
            {
                rmp->regprog->re_in_use = TRUE;
                result = rmp->regprog->engine->regexec_multi(
                                      rmp, win, buf, lnum, col, tm, timed_out);
--- 2890,2905 ----
  #ifdef FEAT_SYN_HL
            reg_do_extmatch = 0;
  #endif
!           if (rmp->regprog == NULL)
            {
+               // Somehow compiling the pattern failed now, put back the
+               // previous one to avoid "regprog" becoming NULL.
+               rmp->regprog = prev_prog;
+           }
+           else
+           {
+               vim_regfree(prev_prog);
+ 
                rmp->regprog->re_in_use = TRUE;
                result = rmp->regprog->engine->regexec_multi(
                                      rmp, win, buf, lnum, col, tm, timed_out);
*** ../vim-8.2.4686/src/version.c       2022-04-04 17:19:57.139569576 +0100
--- src/version.c       2022-04-04 17:52:15.376791260 +0100
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     4687,
  /**/

-- 
The Law, in its majestic equality, forbids the rich, as well as the
poor, to sleep under the bridges, to beg in the streets, and to steal
bread.                       -- Anatole France

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            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/20220404171511.1ADF31C0561%40moolenaar.net.

Raspunde prin e-mail lui