To: vim_dev@googlegroups.com Subject: Patch 8.2.4687 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ 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 -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///