1
0
forked from aniani/vim

patch 8.1.0908: can't handle large value for %{nr}v in regexp

Problem:    Can't handle large value for %{nr}v in regexp. (Kuang-che Wu)
Solution:   Give an error if the value is too large. (closes #3948)
This commit is contained in:
Bram Moolenaar
2019-02-13 18:35:06 +01:00
parent 5382f12c91
commit 9403a2168d
2 changed files with 8 additions and 3 deletions

View File

@@ -1550,6 +1550,8 @@ nfa_regatom(void)
}
if (c == 'l' || c == 'c' || c == 'v')
{
int limit = INT_MAX;
if (c == 'l')
{
/* \%{n}l \%{n}<l \%{n}>l */
@@ -1563,16 +1565,17 @@ nfa_regatom(void)
EMIT(cmp == '<' ? NFA_COL_LT :
cmp == '>' ? NFA_COL_GT : NFA_COL);
else
{
/* \%{n}v \%{n}<v \%{n}>v */
EMIT(cmp == '<' ? NFA_VCOL_LT :
cmp == '>' ? NFA_VCOL_GT : NFA_VCOL);
#if VIM_SIZEOF_INT < VIM_SIZEOF_LONG
if (n > INT_MAX)
limit = INT_MAX / MB_MAXBYTES;
}
if (n >= limit)
{
emsg(_("E951: \\% value too large"));
return FAIL;
}
#endif
EMIT((int)n);
break;
}

View File

@@ -783,6 +783,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
908,
/**/
907,
/**/