diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-06-23 14:21:42 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-06-23 14:21:42 +0200 |
commit | bcf9442307075bac40d44328c8bf7ea21857b138 (patch) | |
tree | 6890b363128e8cbffe09b274ecd1b1665393fac1 /src/regexp_nfa.c | |
parent | 5efa0102de6ed6049fb19e1e83787e5b3b24b6a2 (diff) | |
download | vim-git-bcf9442307075bac40d44328c8bf7ea21857b138.tar.gz |
patch 8.1.0098: segfault when pattern with \z() is very slowv8.1.0098
Problem: Segfault when pattern with \z() is very slow.
Solution: Check for NULL regprog. Add "nfa_fail" to test_override() to be
able to test this. Fix that 'searchhl' resets called_emsg.
Diffstat (limited to 'src/regexp_nfa.c')
-rw-r--r-- | src/regexp_nfa.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index 0ead03af0..e6296993d 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -1482,7 +1482,7 @@ nfa_regatom(void) case '8': case '9': /* \z1...\z9 */ - if (reg_do_extmatch != REX_USE) + if ((reg_do_extmatch & REX_USE) == 0) EMSG_RET_FAIL(_(e_z1_not_allowed)); EMIT(NFA_ZREF1 + (no_Magic(c) - '1')); /* No need to set nfa_has_backref, the sub-matches don't @@ -1491,7 +1491,7 @@ nfa_regatom(void) break; case '(': /* \z( */ - if (reg_do_extmatch != REX_SET) + if ((reg_do_extmatch & REX_SET) == 0) EMSG_RET_FAIL(_(e_z_not_allowed)); if (nfa_reg(REG_ZPAREN) == FAIL) return FAIL; /* cascaded error */ @@ -5692,7 +5692,8 @@ nfa_regmatch( nextlist->n = 0; /* clear nextlist */ nextlist->has_pim = FALSE; ++nfa_listid; - if (prog->re_engine == AUTOMATIC_ENGINE && nfa_listid >= NFA_MAX_STATES) + if (prog->re_engine == AUTOMATIC_ENGINE + && (nfa_listid >= NFA_MAX_STATES || nfa_fail_for_testing)) { /* too many states, retry with old engine */ nfa_match = NFA_TOO_EXPENSIVE; |