Skip to content

Commit 4659c12

Browse files
committed
Fix #79846: 8c67c16 broke simple regexp
We backport the respective upstream fix[1]. [1] <https://vcs.pcre.org/pcre2?view=revision&revision=1267>
1 parent 03a98d9 commit 4659c12

File tree

2 files changed

+29
-12
lines changed

2 files changed

+29
-12
lines changed

ext/pcre/pcre2lib/pcre2_jit_compile.c

+12-12
Original file line numberDiff line numberDiff line change
@@ -1466,9 +1466,9 @@ do
14661466
default:
14671467
accelerated_start = NULL;
14681468
fast_forward_allowed = FALSE;
1469-
break;
1469+
continue;
14701470
}
1471-
continue;
1471+
break;
14721472

14731473
case OP_ONCE:
14741474
case OP_BRA:
@@ -1834,57 +1834,57 @@ while (cc < ccend)
18341834
case OP_BRAZERO:
18351835
case OP_BRAMINZERO:
18361836
case OP_BRAPOSZERO:
1837-
repeat_check = FALSE;
18381837
size = 1;
1838+
repeat_check = FALSE;
18391839
break;
18401840

18411841
CASE_ITERATOR_PRIVATE_DATA_1
1842-
space = 1;
18431842
size = -2;
1843+
space = 1;
18441844
break;
18451845

18461846
CASE_ITERATOR_PRIVATE_DATA_2A
1847-
space = 2;
18481847
size = -2;
1848+
space = 2;
18491849
break;
18501850

18511851
CASE_ITERATOR_PRIVATE_DATA_2B
1852-
space = 2;
18531852
size = -(2 + IMM2_SIZE);
1853+
space = 2;
18541854
break;
18551855

18561856
CASE_ITERATOR_TYPE_PRIVATE_DATA_1
1857-
space = 1;
18581857
size = 1;
1858+
space = 1;
18591859
break;
18601860

18611861
CASE_ITERATOR_TYPE_PRIVATE_DATA_2A
1862+
size = 1;
18621863
if (cc[1] != OP_ANYNL && cc[1] != OP_EXTUNI)
18631864
space = 2;
1864-
size = 1;
18651865
break;
18661866

18671867
case OP_TYPEUPTO:
1868+
size = 1 + IMM2_SIZE;
18681869
if (cc[1 + IMM2_SIZE] != OP_ANYNL && cc[1 + IMM2_SIZE] != OP_EXTUNI)
18691870
space = 2;
1870-
size = 1 + IMM2_SIZE;
18711871
break;
18721872

18731873
case OP_TYPEMINUPTO:
1874-
space = 2;
18751874
size = 1 + IMM2_SIZE;
1875+
space = 2;
18761876
break;
18771877

18781878
case OP_CLASS:
18791879
case OP_NCLASS:
1880-
space = get_class_iterator_size(cc + size);
18811880
size = 1 + 32 / sizeof(PCRE2_UCHAR);
1881+
space = get_class_iterator_size(cc + size);
18821882
break;
18831883

18841884
#if defined SUPPORT_UNICODE || PCRE2_CODE_UNIT_WIDTH != 8
18851885
case OP_XCLASS:
1886-
space = get_class_iterator_size(cc + size);
18871886
size = GET(cc, 1);
1887+
space = get_class_iterator_size(cc + size);
18881888
break;
18891889
#endif
18901890

ext/pcre/tests/bug79846.phpt

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Bug #79846 (8c67c166996 broke simple regexp)
3+
--FILE--
4+
<?php
5+
$item = "component_phase_1";
6+
preg_match("/([a-z]+_[a-z]+_*[a-z]+)_?(\d+)?/", $item, $match);
7+
var_dump($match);
8+
?>
9+
--EXPECT--
10+
array(3) {
11+
[0]=>
12+
string(17) "component_phase_1"
13+
[1]=>
14+
string(15) "component_phase"
15+
[2]=>
16+
string(1) "1"
17+
}

0 commit comments

Comments
 (0)