]> granicus.if.org Git - vim/commitdiff
patch 8.2.4901: NULL pointer access when using invalid pattern v8.2.4901
authorBram Moolenaar <Bram@vim.org>
Sat, 7 May 2022 10:28:06 +0000 (11:28 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 7 May 2022 10:28:06 +0000 (11:28 +0100)
Problem:    NULL pointer access when using invalid pattern.
Solution:   Check for failed regexp program.

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

index 461950307c4d0ff9b449bc4d5724a4c48f252bab..da0555e86f6de2b0495bd590f89d07fb7f698b9a 100644 (file)
@@ -2957,7 +2957,7 @@ fname_match(
        rmp->rm_ic = p_fic || ignore_case;
        if (vim_regexec(rmp, name, (colnr_T)0))
            match = name;
-       else
+       else if (rmp->regprog != NULL)
        {
            // Replace $(HOME) with '~' and try matching again.
            p = home_replace_save(NULL, name);
index fc391dcceee614f89f9479c6abfa98ea9da4bc92..aea3995587078553467a6a08f2871faa36165346 100644 (file)
@@ -410,6 +410,13 @@ func Test_buffer_scheme()
   set shellslash&
 endfunc
 
+" this was using a NULL pointer after failing to use the pattern
+func Test_buf_pattern_invalid()
+  vsplit 0000000
+  silent! buf [0--]\&\zs*\zs*e
+  bwipe!
+endfunc
+
 " Test for the 'maxmem' and 'maxmemtot' options
 func Test_buffer_maxmem()
   " use 1KB per buffer and 2KB for all the buffers
index ad38b8138e92901f723ad439c94011228696b598..647011ae13ac6155d6a29e8c4fe701f9ec64aafa 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4901,
 /**/
     4900,
 /**/