changeset 28753:6e55b7b30df5 v8.2.4901

patch 8.2.4901: NULL pointer access when using invalid pattern Commit: https://github.com/vim/vim/commit/8e4b76da1d7e987d43ca960dfbc372d1c617466f Author: Bram Moolenaar <Bram@vim.org> Date: Sat May 7 11:28:06 2022 +0100 patch 8.2.4901: NULL pointer access when using invalid pattern Problem: NULL pointer access when using invalid pattern. Solution: Check for failed regexp program.
author Bram Moolenaar <Bram@vim.org>
date Sat, 07 May 2022 12:30:03 +0200
parents 89c01001c45f
children 082a1aa2c3ab
files src/buffer.c src/testdir/test_buffer.vim src/version.c
diffstat 3 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -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);
--- a/src/testdir/test_buffer.vim
+++ b/src/testdir/test_buffer.vim
@@ -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
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    4901,
+/**/
     4900,
 /**/
     4899,