vim-patch:7.4.421

Problem:    Crash when searching for "\ze*". (Urtica Dioica)
Solution:   Disallow a multi after \ze and \zs.

https://code.google.com/p/vim/source/detail?r=v7-4-421
This commit is contained in:
Scott Prager
2014-10-21 11:08:35 -04:00
committed by Justin M. Keyes
parent c5d7d75bb1
commit 44635add18
4 changed files with 31 additions and 3 deletions

View File

@@ -1259,10 +1259,16 @@ static int nfa_regatom(void)
switch (c) { switch (c) {
case 's': case 's':
EMIT(NFA_ZSTART); EMIT(NFA_ZSTART);
if (!re_mult_next("\\zs")) {
return false;
}
break; break;
case 'e': case 'e':
EMIT(NFA_ZEND); EMIT(NFA_ZEND);
nfa_has_zend = TRUE; nfa_has_zend = true;
if (!re_mult_next("\\zs")) {
return false;
}
break; break;
case '1': case '1':
case '2': case '2':
@@ -1741,6 +1747,15 @@ nfa_do_multibyte:
return OK; return OK;
} }
/// Used in a place where no * or \+ can follow.
static bool re_mult_next(char *what)
{
if (re_multi_type(peekchr()) == MULTI_MULT) {
EMSG2_RET_FAIL(_("E888: (NFA regexp) cannot repeat %s"), what);
}
return true;
}
/* /*
* Parse something followed by possible [*+=]. * Parse something followed by possible [*+=].
* *

View File

@@ -459,7 +459,7 @@ STARTTEST
: let text = t[2] : let text = t[2]
: let matchidx = 3 : let matchidx = 3
: for engine in [0, 1, 2] : for engine in [0, 1, 2]
: if engine == 2 && re == 0 || engine == 1 && re ==1 : if engine == 2 && re == 0 || engine == 1 && re == 1
: continue : continue
: endif : endif
: let &regexpengine = engine : let &regexpengine = engine
@@ -608,6 +608,17 @@ yeGopA END:"
"ayb20gg/..\%$ "ayb20gg/..\%$
"bybGo"apo"bp:" "bybGo"apo"bp:"
:" :"
:" Check for detecting error
:set regexpengine=2
:for pat in [' \ze*', ' \zs*']
: try
: let l = matchlist('x x', pat)
: $put ='E888 NOT detected for ' . pat
: catch
: $put ='E888 detected for ' . pat
: endtry
:endfor
:"
:""""" Write the results """"""""""""" :""""" Write the results """""""""""""
:/\%#=1^Results/,$wq! test.out :/\%#=1^Results/,$wq! test.out
ENDTEST ENDTEST

View File

@@ -1097,3 +1097,5 @@ Test
Test END Test END
EN EN
E E
E888 detected for \ze*
E888 detected for \zs*

View File

@@ -244,7 +244,7 @@ static int included_patches[] = {
//424 NA //424 NA
//423, //423,
//422, //422,
//421, 421,
//420 NA //420 NA
419, 419,
418, 418,