changeset 15856:e44b7caaf373 v8.1.0935

patch 8.1.0935: old regexp engine may use invalid buffer commit https://github.com/vim/vim/commit/8bfd9469cef536f171e6666f9d9217192e09d161 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Feb 16 18:07:57 2019 +0100 patch 8.1.0935: old regexp engine may use invalid buffer Problem: Old regexp engine may use invalid buffer for 'iskeyword' or uninitialized buffer pointer. (Kuang-che Wu) Solution: Set rex.reg_buf when compiling the pattern. (closes #3972)
author Bram Moolenaar <Bram@vim.org>
date Sat, 16 Feb 2019 18:15:05 +0100
parents defb99439bca
children d06d39fecfea
files src/regexp.c src/testdir/test_regexp_latin.vim src/version.c
diffstat 3 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -7998,6 +7998,8 @@ vim_regcomp(char_u *expr_arg, int re_fla
     bt_regengine.expr = expr;
     nfa_regengine.expr = expr;
 #endif
+    // reg_iswordc() uses rex.reg_buf
+    rex.reg_buf = curbuf;
 
     /*
      * First try the NFA engine, unless backtracking was requested.
--- a/src/testdir/test_regexp_latin.vim
+++ b/src/testdir/test_regexp_latin.vim
@@ -104,3 +104,19 @@ func Test_get_equi_class()
   s/^/[[=
   call assert_equal(1, search(getline(1)))
 endfunc
+
+func Test_rex_init()
+  set noincsearch
+  set re=1
+  new
+  setlocal iskeyword=a-z
+  call setline(1, ['abc', 'ABC'])
+  call assert_equal(1, search('[[:keyword:]]'))
+  new
+  setlocal iskeyword=A-Z
+  call setline(1, ['abc', 'ABC'])
+  call assert_equal(2, search('[[:keyword:]]'))
+  bwipe!
+  bwipe!
+  set re=0
+endfunc
--- a/src/version.c
+++ b/src/version.c
@@ -780,6 +780,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    935,
+/**/
     934,
 /**/
     933,