aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-05-11 19:47:05 +0800
committerGitHub <noreply@github.com>2022-05-11 19:47:05 +0800
commitb13089c9569e8c61d644c2e50eee747aa2fbb9ef (patch)
tree94f9ec5a77f65f90240c229736f7089fb58f3268
parent96a125b2076f75d4273acd1ddcf66e76190b0857 (diff)
parent6f52bc5dee23e85d07eb7a32d4cbea633f9939ef (diff)
downloadrneovim-b13089c9569e8c61d644c2e50eee747aa2fbb9ef.tar.gz
rneovim-b13089c9569e8c61d644c2e50eee747aa2fbb9ef.tar.bz2
rneovim-b13089c9569e8c61d644c2e50eee747aa2fbb9ef.zip
Merge pull request #18522 from zeertzjq/vim-8.2.4901
vim-patch:8.2.{4901,4938}: NULL pointer access when using invalid pattern
-rw-r--r--src/nvim/buffer.c4
-rw-r--r--src/nvim/testdir/test_buffer.vim11
2 files changed, 13 insertions, 2 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index ab804cc42f..2c9f997ac1 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -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)) {
diff --git a/src/nvim/testdir/test_buffer.vim b/src/nvim/testdir/test_buffer.vim
index a31cdbb49a..9eb768f124 100644
--- a/src/nvim/testdir/test_buffer.vim
+++ b/src/nvim/testdir/test_buffer.vim
@@ -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