Mercurial > vim
comparison src/regexp_nfa.c @ 14161:7cac4646c552 v8.1.0098
patch 8.1.0098: segfault when pattern with z() is very slow
commit https://github.com/vim/vim/commit/bcf9442307075bac40d44328c8bf7ea21857b138
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jun 23 14:21:42 2018 +0200
patch 8.1.0098: segfault when pattern with \z() is very slow
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.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 23 Jun 2018 14:30:07 +0200 |
parents | c9342023ea6f |
children | 99a96be12254 |
comparison
equal
deleted
inserted
replaced
14160:de4575cbbb2b | 14161:7cac4646c552 |
---|---|
1480 case '6': | 1480 case '6': |
1481 case '7': | 1481 case '7': |
1482 case '8': | 1482 case '8': |
1483 case '9': | 1483 case '9': |
1484 /* \z1...\z9 */ | 1484 /* \z1...\z9 */ |
1485 if (reg_do_extmatch != REX_USE) | 1485 if ((reg_do_extmatch & REX_USE) == 0) |
1486 EMSG_RET_FAIL(_(e_z1_not_allowed)); | 1486 EMSG_RET_FAIL(_(e_z1_not_allowed)); |
1487 EMIT(NFA_ZREF1 + (no_Magic(c) - '1')); | 1487 EMIT(NFA_ZREF1 + (no_Magic(c) - '1')); |
1488 /* No need to set nfa_has_backref, the sub-matches don't | 1488 /* No need to set nfa_has_backref, the sub-matches don't |
1489 * change when \z1 .. \z9 matches or not. */ | 1489 * change when \z1 .. \z9 matches or not. */ |
1490 re_has_z = REX_USE; | 1490 re_has_z = REX_USE; |
1491 break; | 1491 break; |
1492 case '(': | 1492 case '(': |
1493 /* \z( */ | 1493 /* \z( */ |
1494 if (reg_do_extmatch != REX_SET) | 1494 if ((reg_do_extmatch & REX_SET) == 0) |
1495 EMSG_RET_FAIL(_(e_z_not_allowed)); | 1495 EMSG_RET_FAIL(_(e_z_not_allowed)); |
1496 if (nfa_reg(REG_ZPAREN) == FAIL) | 1496 if (nfa_reg(REG_ZPAREN) == FAIL) |
1497 return FAIL; /* cascaded error */ | 1497 return FAIL; /* cascaded error */ |
1498 re_has_z = REX_SET; | 1498 re_has_z = REX_SET; |
1499 break; | 1499 break; |
5690 thislist = &list[flag]; | 5690 thislist = &list[flag]; |
5691 nextlist = &list[flag ^= 1]; | 5691 nextlist = &list[flag ^= 1]; |
5692 nextlist->n = 0; /* clear nextlist */ | 5692 nextlist->n = 0; /* clear nextlist */ |
5693 nextlist->has_pim = FALSE; | 5693 nextlist->has_pim = FALSE; |
5694 ++nfa_listid; | 5694 ++nfa_listid; |
5695 if (prog->re_engine == AUTOMATIC_ENGINE && nfa_listid >= NFA_MAX_STATES) | 5695 if (prog->re_engine == AUTOMATIC_ENGINE |
5696 && (nfa_listid >= NFA_MAX_STATES || nfa_fail_for_testing)) | |
5696 { | 5697 { |
5697 /* too many states, retry with old engine */ | 5698 /* too many states, retry with old engine */ |
5698 nfa_match = NFA_TOO_EXPENSIVE; | 5699 nfa_match = NFA_TOO_EXPENSIVE; |
5699 goto theend; | 5700 goto theend; |
5700 } | 5701 } |