Skip to content

Commit 10ae0e2

Browse files
committed
[Bug 17190] Add test for PCRE recursion-based stack overflow
Add a suitably simple-yet-abusive `matchText()` recursion test that causes a stack overflow, in the hope that it'll prevent bug 17190 (and indeed bug 16) from regressing again next time we update PCRE.
1 parent 2a86908 commit 10ae0e2

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
script "CoreStringsMatchText"
2+
3+
-- Bug 16: Ensure that very deeply recursive regular expressions do
4+
-- not cause a stack overflow in libpcre
5+
constant kRecursionExpr = "x(?R)?"
6+
constant kRecursionLength = 16384
7+
8+
on TestMatchTextRecursion
9+
10+
-- Build a suitably long string
11+
local tTarget
12+
put "x" into tTarget
13+
repeat
14+
if length(tTarget) >= kRecursionLength then
15+
delete char (1+kRecursionLength) to -1 of tTarget
16+
exit repeat
17+
end if
18+
put tTarget after tTarget
19+
end repeat
20+
21+
get matchText(tTarget, kRecursionExpr)
22+
23+
end TestMatchTextRecursion

0 commit comments

Comments
 (0)