Skip to content

Commit

Permalink
patch 8.2.4440: crash with specific regexp pattern and string
Browse files Browse the repository at this point in the history
Problem:    Crash with specific regexp pattern and string.
Solution:   Stop at the start of the string.
  • Loading branch information
brammool committed Feb 22, 2022
1 parent 1349bd7 commit 6456fae
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/regexp_bt.c
Expand Up @@ -4615,6 +4615,11 @@ regmatch(
if (rex.input == rex.line)
{
// backup to last char of previous line
if (rex.lnum == 0)
{
status = RA_NOMATCH;
break;
}
--rex.lnum;
rex.line = reg_getline(rex.lnum);
// Just in case regrepeat() didn't count
Expand Down
12 changes: 10 additions & 2 deletions src/testdir/test_regexp_utf8.vim
Expand Up @@ -508,7 +508,6 @@ endfunc
" Check that [[:upper:]] matches for automatic engine
func Test_match_char_class_upper()
new
let _engine=&regexpengine

" Test 1: [[:upper:]]\{2,\}
set regexpengine=0
Expand Down Expand Up @@ -549,7 +548,7 @@ func Test_match_char_class_upper()
call assert_equal(4, searchcount().total, 'TEST 3 lower')

" clean up
let &regexpengine=_engine
set regexpengine=0
bwipe!
endfunc

Expand All @@ -561,4 +560,13 @@ func Test_match_invalid_byte()
call delete('Xinvalid')
endfunc

func Test_match_too_complicated()
set regexpengine=1
exe "vsplit \xeb\xdb\x99"
silent! buf \&\zs*\zs*0
bwipe!
set regexpengine=0
endfunc


" vim: shiftwidth=2 sts=2 expandtab
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -750,6 +750,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4440,
/**/
4439,
/**/
Expand Down

0 comments on commit 6456fae

Please sign in to comment.