Skip to content

Commit 0d7159c

Browse files
PhilipHazelNWilson
authored andcommitted
Fix incorrect compiling when variable-length lookbehind's first branch was not the shortest and there was a backreference to a groupwithin the lookbehind.
Cherry-picked from 4a6a8b0.
1 parent c0fdb5f commit 0d7159c

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/pcre2_compile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9908,7 +9908,7 @@ do
99089908
*bptr |= branchlength; /* branchlength never more than 65535 */
99099909
bptr = *pptrptr;
99109910
}
9911-
while (*bptr == META_ALT);
9911+
while (META_CODE(*bptr) == META_ALT);
99129912

99139913
/* If any branch is of variable length, the whole lookbehind is of variable
99149914
length. If the maximum length of any branch exceeds the maximum for variable

testdata/testinput2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6099,4 +6099,8 @@ a)"xI
60996099
/(a(?1)z||(?1)++)$/
61006100
abcd\=disable_recurseloop_check
61016101

6102+
/(((?<=123?456456|ABC)))(?<=\2)../
6103+
ABCDEFG
6104+
12345645678910
6105+
61026106
# End of testinput2

testdata/testoutput2

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18038,6 +18038,16 @@ Failed: error -47: match limit exceeded
1803818038
0:
1803918039
1:
1804018040

18041+
/(((?<=123?456456|ABC)))(?<=\2)../
18042+
ABCDEFG
18043+
0: DE
18044+
1:
18045+
2:
18046+
12345645678910
18047+
0: 78
18048+
1:
18049+
2:
18050+
1804118051
# End of testinput2
1804218052
Error -70: PCRE2_ERROR_BADDATA (unknown error number)
1804318053
Error -62: bad serialized data

0 commit comments

Comments
 (0)