summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2014-08-29 11:56:32 +0200
committerBram Moolenaar <Bram@vim.org>2014-08-29 11:56:32 +0200
commit2d46e6075ba3aa369172e610782810b9ac3f1f4b (patch)
tree82015972dbb87c03b480a2f0eb305fa216803f20
parenta9537d238e8c2fe9afb9bbf4e137734372b7d9ba (diff)
downloadvim-git-2d46e6075ba3aa369172e610782810b9ac3f1f4b.tar.gz
updated for version 7.4.421v7.4.421
Problem: Crash when searching for "\ze*". (Urtica Dioica) Solution: Disallow a multi after \ze and \zs.
-rw-r--r--src/regexp_nfa.c17
-rw-r--r--src/testdir/test64.in13
-rw-r--r--src/testdir/test64.ok2
-rw-r--r--src/version.c2
4 files changed, 33 insertions, 1 deletions
diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c
index a7fbe7b25..4ccb05a2b 100644
--- a/src/regexp_nfa.c
+++ b/src/regexp_nfa.c
@@ -291,6 +291,7 @@ static int nfa_regpiece __ARGS((void));
static int nfa_regconcat __ARGS((void));
static int nfa_regbranch __ARGS((void));
static int nfa_reg __ARGS((int paren));
+static int re_mult_next __ARGS((char *what));
#ifdef DEBUG
static void nfa_set_code __ARGS((int c));
static void nfa_postfix_dump __ARGS((char_u *expr, int retval));
@@ -1323,10 +1324,14 @@ nfa_regatom()
{
case 's':
EMIT(NFA_ZSTART);
+ if (re_mult_next("\\zs") == FAIL)
+ return FAIL;
break;
case 'e':
EMIT(NFA_ZEND);
nfa_has_zend = TRUE;
+ if (re_mult_next("\\ze") == FAIL)
+ return FAIL;
break;
#ifdef FEAT_SYN_HL
case '1':
@@ -2276,6 +2281,18 @@ nfa_reg(paren)
return OK;
}
+/*
+ * Used in a place where no * or \+ can follow.
+ */
+ static int
+re_mult_next(what)
+ char *what;
+{
+ if (re_multi_type(peekchr()) == MULTI_MULT)
+ EMSG2_RET_FAIL(_("E888: (NFA regexp) cannot repeat %s"), what);
+ return OK;
+}
+
#ifdef DEBUG
static char_u code[50];
diff --git a/src/testdir/test64.in b/src/testdir/test64.in
index 2abdcd1c0..f2452fc0f 100644
--- a/src/testdir/test64.in
+++ b/src/testdir/test64.in
@@ -459,7 +459,7 @@ STARTTEST
: let text = t[2]
: let matchidx = 3
: 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
: endif
: let &regexpengine = engine
@@ -608,6 +608,17 @@ yeGopA END:"
"ayb20gg/..\%$
"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 """""""""""""
:/\%#=1^Results/,$wq! test.out
ENDTEST
diff --git a/src/testdir/test64.ok b/src/testdir/test64.ok
index e7d173141..ffc0b5341 100644
--- a/src/testdir/test64.ok
+++ b/src/testdir/test64.ok
@@ -1097,3 +1097,5 @@ Test
Test END
EN
E
+E888 detected for \ze*
+E888 detected for \zs*
diff --git a/src/version.c b/src/version.c
index a34bef22b..d047c9b8d 100644
--- a/src/version.c
+++ b/src/version.c
@@ -742,6 +742,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 421,
+/**/
420,
/**/
419,