From 486234ab3db56621767bea18a1783d289b660764 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 17 Feb 2019 19:36:21 -0500 Subject: [PATCH] vim-patch:8.1.0937: invalid memory access in search pattern Problem: Invalid memory access in search pattern. (Kuang-che Wu) Solution: Check for incomplete collation element. (Dominique Pelle, closes vim/vim#3985) https://github.com/vim/vim/commit/f1b57ab2ab18032d19f64bff7d22f3adb3fe93f7 --- src/nvim/regexp.c | 2 +- src/nvim/testdir/test_regexp_latin.vim | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index b7fc39fdb3..53479294de 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -1103,7 +1103,7 @@ static int get_coll_element(char_u **pp) int l = 1; char_u *p = *pp; - if (p[0] != NUL && p[1] == '.') { + if (p[0] != NUL && p[1] == '.' && p[2] != NUL) { l = utfc_ptr2len(p + 2); if (p[l + 2] == '.' && p[l + 3] == ']') { c = utf_ptr2char(p + 2); diff --git a/src/nvim/testdir/test_regexp_latin.vim b/src/nvim/testdir/test_regexp_latin.vim index adbded128f..eb8f69ef15 100644 --- a/src/nvim/testdir/test_regexp_latin.vim +++ b/src/nvim/testdir/test_regexp_latin.vim @@ -44,4 +44,6 @@ func Test_get_equi_class() " Incomplete equivalence class caused invalid memory access s/^/[[= call assert_equal(1, search(getline(1))) + s/.*/[[. + call assert_equal(1, search(getline(1))) endfunc