mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.1.1720: crash with very long %[] pattern
Problem: Crash with very long %[] pattern. (Reza Mirzazade farkhani) Solution: Check for reg_toolong. (closes #4703)
This commit is contained in:
@@ -2175,7 +2175,11 @@ regatom(int *flagp)
|
|||||||
if (ret == NULL)
|
if (ret == NULL)
|
||||||
ret = br;
|
ret = br;
|
||||||
else
|
else
|
||||||
|
{
|
||||||
regtail(lastnode, br);
|
regtail(lastnode, br);
|
||||||
|
if (reg_toolong)
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
ungetchr();
|
ungetchr();
|
||||||
one_exactly = TRUE;
|
one_exactly = TRUE;
|
||||||
@@ -2200,6 +2204,8 @@ regatom(int *flagp)
|
|||||||
if (OP(br) == BRANCH)
|
if (OP(br) == BRANCH)
|
||||||
{
|
{
|
||||||
regtail(br, lastbranch);
|
regtail(br, lastbranch);
|
||||||
|
if (reg_toolong)
|
||||||
|
return NULL;
|
||||||
br = OPERAND(br);
|
br = OPERAND(br);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -206,3 +206,12 @@ func Test_large_class()
|
|||||||
call assert_equal(1, "\u3042" =~# '[\u3000-\u4000]')
|
call assert_equal(1, "\u3042" =~# '[\u3000-\u4000]')
|
||||||
set re=0
|
set re=0
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_optmatch_toolong()
|
||||||
|
set re=1
|
||||||
|
" Can only handle about 8000 characters.
|
||||||
|
let pat = '\\%[' .. repeat('x', 9000) .. ']'
|
||||||
|
call assert_fails('call match("abc def", "' .. pat .. '")', 'E339:')
|
||||||
|
set re=0
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
@@ -777,6 +777,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1720,
|
||||||
/**/
|
/**/
|
||||||
1719,
|
1719,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user