Merge pull request #18522 from zeertzjq/vim-8.2.4901

vim-patch:8.2.{4901,4938}: NULL pointer access when using invalid pattern
This commit is contained in:
zeertzjq 2022-05-11 19:47:05 +08:00 committed by GitHub
commit b13089c956
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -2366,7 +2366,7 @@ static char_u *buflist_match(regmatch_T *rmp, buf_T *buf, bool ignore_case)
{
// First try the short file name, then the long file name.
char_u *match = fname_match(rmp, buf->b_sfname, ignore_case);
if (match == NULL) {
if (match == NULL && rmp->regprog != NULL) {
match = fname_match(rmp, buf->b_ffname, ignore_case);
}
return match;
@ -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,15 @@ 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!
vsplit 00000000000000000000000000
silent! buf [0--]\&\zs*\zs*e
bwipe!
endfunc
" vim: shiftwidth=2 sts=2 expandtab