From 43f4e5d5be44c4d836eabd479dcee9ff7d3bfa2a Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 23 Jul 2019 22:54:14 -0400 Subject: 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 --- src/nvim/regexp_nfa.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') 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 EMIT(cmp == '<' ? NFA_LNUM_LT : @@ -1518,13 +1520,12 @@ static int nfa_regatom(void) // \%{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) { -- cgit