45 lines
1.3 KiB
Diff
45 lines
1.3 KiB
Diff
From a59f2dfd0cf9ee1a584d3de5b7c2d47648e79060 Mon Sep 17 00:00:00 2001
|
|
From: Bram Moolenaar <Bram@vim.org>
|
|
Date: Wed, 11 May 2022 11:42:28 +0100
|
|
Subject: [PATCH] patch 8.2.4938: crash when matching buffer with invalid
|
|
pattern
|
|
|
|
Problem: Crash when matching buffer with invalid pattern.
|
|
Solution: Check for NULL regprog.
|
|
---
|
|
src/buffer.c | 2 +-
|
|
src/testdir/test_buffer.vim | 4 ++++
|
|
2 files changed, 5 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/buffer.c b/src/buffer.c
|
|
index 758d920..88094ee 100644
|
|
--- a/src/buffer.c
|
|
+++ b/src/buffer.c
|
|
@@ -2805,7 +2805,7 @@ buflist_match(
|
|
|
|
// First try the short file name, then the long file name.
|
|
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/testdir/test_buffer.vim b/src/testdir/test_buffer.vim
|
|
index 8300f3d..6039ff8 100644
|
|
--- a/src/testdir/test_buffer.vim
|
|
+++ b/src/testdir/test_buffer.vim
|
|
@@ -68,6 +68,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
|
|
--
|
|
1.8.3.1
|
|
|