summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-05-07 11:28:06 +0100
committerBram Moolenaar <Bram@vim.org>2022-05-07 11:28:06 +0100
commit8e4b76da1d7e987d43ca960dfbc372d1c617466f (patch)
treeefbe309a2616fba361717918f55923a19dd65e04
parent801c3c1dbed88bfb59dcf25045365dc65f795f4e (diff)
downloadvim-git-8e4b76da1d7e987d43ca960dfbc372d1c617466f.tar.gz
patch 8.2.4901: NULL pointer access when using invalid patternv8.2.4901
Problem: NULL pointer access when using invalid pattern. Solution: Check for failed regexp program.
-rw-r--r--src/buffer.c2
-rw-r--r--src/testdir/test_buffer.vim7
-rw-r--r--src/version.c2
3 files changed, 10 insertions, 1 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 461950307..da0555e86 100644
--- 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);
diff --git a/src/testdir/test_buffer.vim b/src/testdir/test_buffer.vim
index fc391dcce..aea399558 100644
--- 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
diff --git a/src/version.c b/src/version.c
index ad38b8138..647011ae1 100644
--- 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,