aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-03-07 06:05:22 -0500
committerJustin M. Keyes <justinkz@gmail.com>2019-03-07 12:05:22 +0100
commit5f84b1dc4154ea8def87b6113fa9b9ed058d83d2 (patch)
tree64cc7986d62463715073960852dcfc56420d6c97 /src
parentb51e5d8b8dd2b5e7c5986f19bdf4130226b47379 (diff)
downloadrneovim-5f84b1dc4154ea8def87b6113fa9b9ed058d83d2.tar.gz
rneovim-5f84b1dc4154ea8def87b6113fa9b9ed058d83d2.tar.bz2
rneovim-5f84b1dc4154ea8def87b6113fa9b9ed058d83d2.zip
vim-patch:8.1.0935: old regexp engine may use invalid buffer #9692
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 vim/vim#3972) https://github.com/vim/vim/commit/8bfd9469cef536f171e6666f9d9217192e09d161
Diffstat (limited to 'src')
-rw-r--r--src/nvim/regexp.c2
-rw-r--r--src/nvim/testdir/test_regexp_latin.vim16
2 files changed, 18 insertions, 0 deletions
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c
index 3b3ca29dad..c043d4a173 100644
--- a/src/nvim/regexp.c
+++ b/src/nvim/regexp.c
@@ -7116,6 +7116,8 @@ regprog_T *vim_regcomp(char_u *expr_arg, int re_flags)
}
bt_regengine.expr = expr;
nfa_regengine.expr = expr;
+ // reg_iswordc() uses rex.reg_buf
+ rex.reg_buf = curbuf;
//
// First try the NFA engine, unless backtracking was requested.
diff --git a/src/nvim/testdir/test_regexp_latin.vim b/src/nvim/testdir/test_regexp_latin.vim
index eb8f69ef15..8f9b1eb7ca 100644
--- a/src/nvim/testdir/test_regexp_latin.vim
+++ b/src/nvim/testdir/test_regexp_latin.vim
@@ -47,3 +47,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