# HG changeset patch # User Bram Moolenaar # Date 1550079906 -3600 # Node ID f043c89315851aa7e8b1c6aae1a7740df2674886 # Parent 669a52a4f9489a71d47760c3e0050266b1a9ee1b patch 8.1.0908: can't handle large value for %{nr}v in regexp commit https://github.com/vim/vim/commit/9403a2168db82b7de80f792984084bb3f00e2263 Author: Bram Moolenaar Date: Wed Feb 13 18:35:06 2019 +0100 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 https://github.com/vim/vim/issues/3948) diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c --- 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 */ @@ -1563,16 +1565,17 @@ nfa_regatom(void) EMIT(cmp == '<' ? NFA_COL_LT : cmp == '>' ? NFA_COL_GT : NFA_COL); else + { /* \%{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; } diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -784,6 +784,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 908, +/**/ 907, /**/ 906,