]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.4938: crash when matching buffer with invalid pattern v8.2.4938
authorBram Moolenaar <Bram@vim.org>
Wed, 11 May 2022 10:42:28 +0000 (11:42 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 11 May 2022 10:42:28 +0000 (11:42 +0100)
Problem:    Crash when matching buffer with invalid pattern.
Solution:   Check for NULL regprog.

src/buffer.c
src/testdir/test_buffer.vim
src/version.c

index 35711f5feb320bc5f58cb34dbf6ae373765a200d..dfdb0c430d95a0965efa6cb1ca74ea8bdc23063d 100644 (file)
@@ -2932,7 +2932,7 @@ buflist_match(
 
     // First try the short file name, then the long file name.
     match = fname_match(rmp, buf->b_sfname, ignore_case);
-    if (match == NULL)
+    if (match == NULL && rmp->regprog != NULL)
        match = fname_match(rmp, buf->b_ffname, ignore_case);
 
     return match;
index aea3995587078553467a6a08f2871faa36165346..55ef0fda76209f2ee60a71894bc70fd9d6a8d05a 100644 (file)
@@ -415,6 +415,10 @@ func Test_buf_pattern_invalid()
   vsplit 0000000
   silent! buf [0--]\&\zs*\zs*e
   bwipe!
+
+  vsplit 00000000000000000000000000
+  silent! buf [0--]\&\zs*\zs*e
+  bwipe!
 endfunc
 
 " Test for the 'maxmem' and 'maxmemtot' options
index 8cc9cebac386382d677d64d053bb4a9d665929bf..0a3a5df8bc97e10ad96892a136ce587027ba6530 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4938,
 /**/
     4937,
 /**/