diff options
author | Bram Moolenaar <Bram@vim.org> | 2015-01-27 12:59:55 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2015-01-27 12:59:55 +0100 |
commit | e0ad365498399c1bd34dd6361b3f7dc38e84e4ca (patch) | |
tree | 11736866896c182b2783ed496e35628e66db5d3d /src/regexp_nfa.c | |
parent | df5caa08f62fe67f11e48771f4a5125ebc5a69b3 (diff) | |
download | vim-git-e0ad365498399c1bd34dd6361b3f7dc38e84e4ca.tar.gz |
updated for version 7.4.593v7.4.593
Problem: Crash when searching for "x\{0,90000}". (Dominique Pelle)
Solution: Bail out from the NFA engine when the max limit is much higher
than the min limit.
Diffstat (limited to 'src/regexp_nfa.c')
-rw-r--r-- | src/regexp_nfa.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index 03d7868fa..2bd75af20 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -244,6 +244,9 @@ static char_u e_nul_found[] = N_("E865: (NFA) Regexp end encountered prematurely static char_u e_misplaced[] = N_("E866: (NFA regexp) Misplaced %c"); static char_u e_ill_char_class[] = N_("E877: (NFA regexp) Invalid character class: %ld"); +/* re_flags passed to nfa_regcomp() */ +static int nfa_re_flags; + /* NFA regexp \ze operator encountered. */ static int nfa_has_zend; @@ -2011,10 +2014,10 @@ nfa_regpiece() * <atom>* */ if (minval == 0 && maxval == MAX_LIMIT) { - if (greedy) + if (greedy) /* { { (match the braces) */ /* \{}, \{0,} */ EMIT(NFA_STAR); - else + else /* { { (match the braces) */ /* \{-}, \{-0,} */ EMIT(NFA_STAR_NONGREEDY); break; @@ -2030,6 +2033,12 @@ nfa_regpiece() return OK; } + /* The engine is very inefficient (uses too many states) when the + * maximum is much larger than the minimum. Bail out if we can + * use the other engine. */ + if ((nfa_re_flags & RE_AUTO) && maxval > minval + 200) + return FAIL; + /* Ignore previous call to nfa_regatom() */ post_ptr = post_start + my_post_start; /* Save parse state after the repeated atom and the \{} */ @@ -7046,6 +7055,7 @@ nfa_regcomp(expr, re_flags) return NULL; nfa_regengine.expr = expr; + nfa_re_flags = re_flags; init_class_tab(); |