]> granicus.if.org Git - vim/commitdiff
patch 8.1.0934: invalid memory access in search pattern v8.1.0934
authorBram Moolenaar <Bram@vim.org>
Sat, 16 Feb 2019 16:07:47 +0000 (17:07 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 16 Feb 2019 16:07:47 +0000 (17:07 +0100)
Problem:    Invalid memory access in search pattern. (Kuang-che Wu)
Solution:   Check for incomplete equivalence class. (closes #3970)

src/regexp.c
src/testdir/test_regexp_latin.vim
src/version.c

index f06e15c83314b942b8465714fa2d92736dec406e..30a604b23679b36e9d518ee1b9ec0ff2d5e2df73 100644 (file)
@@ -730,7 +730,7 @@ get_equi_class(char_u **pp)
     int                l = 1;
     char_u     *p = *pp;
 
-    if (p[1] == '=')
+    if (p[1] == '=' && p[2] != NUL)
     {
        if (has_mbyte)
            l = (*mb_ptr2len)(p + 2);
index bcac6c72c81dd1fb864c7632729c8ea297268566..09104a1423d17d5d540e2e33f8e074860e6a7656 100644 (file)
@@ -97,3 +97,10 @@ func Test_out_of_memory()
   " This will be slow...
   call assert_fails('call search("\\v((n||<)+);")', 'E363:')
 endfunc
+
+func Test_get_equi_class()
+  new
+  " Incomplete equivalence class caused invalid memory access
+  s/^/[[=
+  call assert_equal(1, search(getline(1)))
+endfunc
index 21b9217878e6e0afece3db4f93bfe8c9ae4f101b..dbf40834195220ae1b39029eab500d2f37ab9bd4 100644 (file)
@@ -779,6 +779,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    934,
 /**/
     933,
 /**/