Skip to content

Commit

Permalink
patch 8.2.4901: NULL pointer access when using invalid pattern
Browse files Browse the repository at this point in the history
Problem:    NULL pointer access when using invalid pattern.
Solution:   Check for failed regexp program.
  • Loading branch information
brammool committed May 7, 2022
1 parent 801c3c1 commit 8e4b76d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/buffer.c
Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions src/testdir/test_buffer.vim
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -746,6 +746,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4901,
/**/
4900,
/**/
Expand Down

0 comments on commit 8e4b76d

Please sign in to comment.