aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-05-11 19:10:18 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-05-11 19:13:07 +0800
commit6f52bc5dee23e85d07eb7a32d4cbea633f9939ef (patch)
tree94f9ec5a77f65f90240c229736f7089fb58f3268 /src
parent0019886a84c7dfdaf452c8a715f26eb87c697b1b (diff)
downloadrneovim-6f52bc5dee23e85d07eb7a32d4cbea633f9939ef.tar.gz
rneovim-6f52bc5dee23e85d07eb7a32d4cbea633f9939ef.tar.bz2
rneovim-6f52bc5dee23e85d07eb7a32d4cbea633f9939ef.zip
vim-patch:8.2.4938: crash when matching buffer with invalid pattern
Problem: Crash when matching buffer with invalid pattern. Solution: Check for NULL regprog. https://github.com/vim/vim/commit/a59f2dfd0cf9ee1a584d3de5b7c2d47648e79060
Diffstat (limited to 'src')
-rw-r--r--src/nvim/buffer.c2
-rw-r--r--src/nvim/testdir/test_buffer.vim4
2 files changed, 5 insertions, 1 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index f9ad16e357..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;
diff --git a/src/nvim/testdir/test_buffer.vim b/src/nvim/testdir/test_buffer.vim
index 7734094584..9eb768f124 100644
--- a/src/nvim/testdir/test_buffer.vim
+++ b/src/nvim/testdir/test_buffer.vim
@@ -66,6 +66,10 @@ 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