Skip to content

Commit 8e4b76d

Browse files
committed
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.
1 parent 801c3c1 commit 8e4b76d

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/buffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2957,7 +2957,7 @@ fname_match(
29572957
rmp->rm_ic = p_fic || ignore_case;
29582958
if (vim_regexec(rmp, name, (colnr_T)0))
29592959
match = name;
2960-
else
2960+
else if (rmp->regprog != NULL)
29612961
{
29622962
// Replace $(HOME) with '~' and try matching again.
29632963
p = home_replace_save(NULL, name);

src/testdir/test_buffer.vim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,13 @@ func Test_buffer_scheme()
410410
set shellslash&
411411
endfunc
412412

413+
" this was using a NULL pointer after failing to use the pattern
414+
func Test_buf_pattern_invalid()
415+
vsplit 0000000
416+
silent! buf [0--]\&\zs*\zs*e
417+
bwipe!
418+
endfunc
419+
413420
" Test for the 'maxmem' and 'maxmemtot' options
414421
func Test_buffer_maxmem()
415422
" use 1KB per buffer and 2KB for all the buffers

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,8 @@ static char *(features[]) =
746746

747747
static int included_patches[] =
748748
{ /* Add new patch number below this line */
749+
/**/
750+
4901,
749751
/**/
750752
4900,
751753
/**/

0 commit comments

Comments
 (0)