vim-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.
8e4b76da1d
This commit is contained in:
zeertzjq 2022-05-11 19:07:31 +08:00
parent 96a125b207
commit 0019886a84
2 changed files with 8 additions and 1 deletions

View File

@ -2387,7 +2387,7 @@ static char_u *fname_match(regmatch_T *rmp, char_u *name, bool ignore_case)
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);
if (vim_regexec(rmp, p, (colnr_T)0)) {

View File

@ -61,4 +61,11 @@ 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
" vim: shiftwidth=2 sts=2 expandtab