aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-07-23 22:54:14 -0400
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-07-24 21:43:04 -0400
commit43f4e5d5be44c4d836eabd479dcee9ff7d3bfa2a (patch)
tree67276d28da21c242e1d85885ee9167b6c89b0bb3 /src
parent9ea449085da08eaa5ccb826dd5e37f480c871e79 (diff)
downloadrneovim-43f4e5d5be44c4d836eabd479dcee9ff7d3bfa2a.tar.gz
rneovim-43f4e5d5be44c4d836eabd479dcee9ff7d3bfa2a.tar.bz2
rneovim-43f4e5d5be44c4d836eabd479dcee9ff7d3bfa2a.zip
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 vim/vim#3948) https://github.com/vim/vim/commit/9403a2168db82b7de80f792984084bb3f00e2263
Diffstat (limited to 'src')
-rw-r--r--src/nvim/regexp_nfa.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c
index a8919560a0..ab189c0c03 100644
--- a/src/nvim/regexp_nfa.c
+++ b/src/nvim/regexp_nfa.c
@@ -1503,6 +1503,8 @@ static int nfa_regatom(void)
c = getchr();
}
if (c == 'l' || c == 'c' || c == 'v') {
+ int limit = INT_MAX;
+
if (c == 'l') {
// \%{n}l \%{n}<l \%{n}>l
EMIT(cmp == '<' ? NFA_LNUM_LT :
@@ -1518,13 +1520,12 @@ static int nfa_regatom(void)
// \%{n}v \%{n}<v \%{n}>v
EMIT(cmp == '<' ? NFA_VCOL_LT :
cmp == '>' ? NFA_VCOL_GT : NFA_VCOL);
+ limit = INT_MAX / MB_MAXBYTES;
}
-#if SIZEOF_INT < SIZEOF_LONG
- if (n > INT_MAX) {
+ if (n >= limit) {
EMSG(_("E951: \\% value too large"));
return FAIL;
}
-#endif
EMIT((int)n);
break;
} else if (c == '\'' && n == 0) {