Skip to content

Commit 51ec2c9

Browse files
author
Zoltan Herczeg
committed
Fix incorrect detection of alternatives in first character search.
1 parent 0612ed7 commit 51ec2c9

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Change Log for PCRE2
22
--------------------
33

4+
Version 10.39-RC1 xx-xxx-2021
5+
-----------------------------
6+
7+
1. Fix incorrect detection of alternatives in first character search.
8+
9+
410
Version 10.38 01-October-2021
511
-----------------------------
612

src/pcre2_jit_compile.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,10 +1251,13 @@ SLJIT_ASSERT(*cc == OP_ONCE || *cc == OP_BRA || *cc == OP_CBRA);
12511251
SLJIT_ASSERT(*cc != OP_CBRA || common->optimized_cbracket[GET2(cc, 1 + LINK_SIZE)] != 0);
12521252
SLJIT_ASSERT(start < EARLY_FAIL_ENHANCE_MAX);
12531253

1254+
next_alt = cc + GET(cc, 1);
1255+
if (*next_alt == OP_ALT)
1256+
fast_forward_allowed = FALSE;
1257+
12541258
do
12551259
{
12561260
count = start;
1257-
next_alt = cc + GET(cc, 1);
12581261
cc += 1 + LINK_SIZE + ((*cc == OP_CBRA) ? IMM2_SIZE : 0);
12591262

12601263
while (TRUE)
@@ -1512,7 +1515,7 @@ do
15121515
{
15131516
count++;
15141517

1515-
if (fast_forward_allowed && *next_alt == OP_KET)
1518+
if (fast_forward_allowed)
15161519
{
15171520
common->fast_forward_bc_ptr = accelerated_start;
15181521
common->private_data_ptrs[(accelerated_start + 1) - common->start] = ((*private_data_start) << 3) | type_skip;
@@ -1562,8 +1565,8 @@ do
15621565
else if (result < count)
15631566
result = count;
15641567

1565-
fast_forward_allowed = FALSE;
15661568
cc = next_alt;
1569+
next_alt = cc + GET(cc, 1);
15671570
}
15681571
while (*cc == OP_ALT);
15691572

src/pcre2_jit_test.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ static struct regression_test_case regression_test_cases[] = {
352352
{ MU, A, 0, 0, ".[ab]?.", "xx" },
353353
{ MU, A, 0, 0, "_[ab]+_*a", "_aa" },
354354
{ MU, A, 0, 0, "#(A+)#\\d+", "#A#A#0" },
355+
{ MU, A, 0, 0, "(?P<size>\\d+)m|M", "4M" },
355356

356357
/* Bracket repeats with limit. */
357358
{ MU, A, 0, 0, "(?:(ab){2}){5}M", "abababababababababababM" },

0 commit comments

Comments
 (0)