To: vim_dev@googlegroups.com Subject: Patch 8.1.0908 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.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) Files: src/regexp_nfa.c *** ../vim-8.1.0907/src/regexp_nfa.c 2019-02-13 01:18:34.019341671 +0100 --- src/regexp_nfa.c 2019-02-13 18:32:14.907289010 +0100 *************** *** 1550,1555 **** --- 1550,1557 ---- } if (c == 'l' || c == 'c' || c == 'v') { + int limit = INT_MAX; + if (c == 'l') { /* \%{n}l \%{n}l */ *************** *** 1563,1578 **** 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) { emsg(_("E951: \\% value too large")); return FAIL; } - #endif EMIT((int)n); break; } --- 1565,1581 ---- 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); ! limit = INT_MAX / MB_MAXBYTES; ! } ! if (n >= limit) { emsg(_("E951: \\% value too large")); return FAIL; } EMIT((int)n); break; } *** ../vim-8.1.0907/src/version.c 2019-02-13 01:18:34.019341671 +0100 --- src/version.c 2019-02-13 18:33:56.626681408 +0100 *************** *** 785,786 **** --- 785,788 ---- { /* Add new patch number below this line */ + /**/ + 908, /**/ -- The problem with political jokes is that they get elected. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///