summaryrefslogtreecommitdiff
path: root/src/regexp_nfa.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-02-13 18:35:06 +0100
committerBram Moolenaar <Bram@vim.org>2019-02-13 18:35:06 +0100
commit9403a2168db82b7de80f792984084bb3f00e2263 (patch)
tree25da95208899178b65dd9e65ac417ffb2b80bac8 /src/regexp_nfa.c
parent5382f12c910b7f8e46acdde5488f26a86f9fcac1 (diff)
downloadvim-git-9403a2168db82b7de80f792984084bb3f00e2263.tar.gz
patch 8.1.0908: can't handle large value for %{nr}v in regexpv8.1.0908
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)
Diffstat (limited to 'src/regexp_nfa.c')
-rw-r--r--src/regexp_nfa.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c
index 18bc8d9a6..3e2ef93fa 100644
--- a/src/regexp_nfa.c
+++ b/src/regexp_nfa.c
@@ -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;
}