Skip to content

Commit cfec7a4

Browse files
committed
pcre: Apply upstream patch for bug #81101 to bundled libpcre
Signed-off-by: Anatol Belski <ab@php.net>
1 parent d188ca7 commit cfec7a4

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

ext/pcre/pcre2lib/pcre2_jit_compile.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,15 +1236,16 @@ return TRUE;
12361236
12371237
return: current number of iterators enhanced with fast fail
12381238
*/
1239-
static int detect_early_fail(compiler_common *common, PCRE2_SPTR cc, int *private_data_start, sljit_s32 depth, int start)
1239+
static int detect_early_fail(compiler_common *common, PCRE2_SPTR cc, int *private_data_start,
1240+
sljit_s32 depth, int start, BOOL fast_forward_allowed)
12401241
{
12411242
PCRE2_SPTR begin = cc;
12421243
PCRE2_SPTR next_alt;
12431244
PCRE2_SPTR end;
12441245
PCRE2_SPTR accelerated_start;
1246+
BOOL prev_fast_forward_allowed;
12451247
int result = 0;
12461248
int count;
1247-
BOOL fast_forward_allowed = TRUE;
12481249

12491250
SLJIT_ASSERT(*cc == OP_ONCE || *cc == OP_BRA || *cc == OP_CBRA);
12501251
SLJIT_ASSERT(*cc != OP_CBRA || common->optimized_cbracket[GET2(cc, 1 + LINK_SIZE)] != 0);
@@ -1476,6 +1477,7 @@ do
14761477
case OP_CBRA:
14771478
end = cc + GET(cc, 1);
14781479

1480+
prev_fast_forward_allowed = fast_forward_allowed;
14791481
fast_forward_allowed = FALSE;
14801482
if (depth >= 4)
14811483
break;
@@ -1484,7 +1486,7 @@ do
14841486
if (*end != OP_KET || (*cc == OP_CBRA && common->optimized_cbracket[GET2(cc, 1 + LINK_SIZE)] == 0))
14851487
break;
14861488

1487-
count = detect_early_fail(common, cc, private_data_start, depth + 1, count);
1489+
count = detect_early_fail(common, cc, private_data_start, depth + 1, count, prev_fast_forward_allowed);
14881490

14891491
if (PRIVATE_DATA(cc) != 0)
14901492
common->private_data_ptrs[begin - common->start] = 1;
@@ -13657,7 +13659,7 @@ memset(common->private_data_ptrs, 0, total_length * sizeof(sljit_s32));
1365713659
private_data_size = common->cbra_ptr + (re->top_bracket + 1) * sizeof(sljit_sw);
1365813660

1365913661
if ((re->overall_options & PCRE2_ANCHORED) == 0 && (re->overall_options & PCRE2_NO_START_OPTIMIZE) == 0 && !common->has_skip_in_assert_back)
13660-
detect_early_fail(common, common->start, &private_data_size, 0, 0);
13662+
detect_early_fail(common, common->start, &private_data_size, 0, 0, TRUE);
1366113663

1366213664
set_private_data_ptrs(common, &private_data_size, ccend);
1366313665

ext/pcre/php_pcre.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ static zend_always_inline size_t calculate_unit_length(pcre_cache_entry *pce, co
595595
PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, int locale_aware)
596596
{
597597
pcre2_code *re = NULL;
598-
#if 10 == PCRE2_MAJOR && 37 == PCRE2_MINOR
598+
#if 10 == PCRE2_MAJOR && 37 == PCRE2_MINOR && !HAVE_BUNDLED_PCRE
599599
uint32_t coptions = PCRE2_NO_START_OPTIMIZE;
600600
#else
601601
uint32_t coptions = 0;

0 commit comments

Comments
 (0)