Skip to content

Commit 1a7f3c0

Browse files
committed
Merge branch 'PHP-8.5'
* PHP-8.5: ext/dom: fix phpGH-22570 new test
2 parents 750074b + 1e6f8df commit 1a7f3c0

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

ext/dom/tests/modern/xml/gh22570.phpt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ if (getenv('SKIP_ASAN')) {
1515
zend.max_allowed_stack_size=512K
1616
--FILE--
1717
<?php
18-
// Build via the DOM API, not the parser: libxml caps parse depth even with
19-
// LIBXML_PARSEHUGE on some platforms; the serializer recursion is the bug.
18+
// Build bottom-up so the insertion cycle-check stays O(1); top-down is O(n^2).
2019
$doc = Dom\XMLDocument::createEmpty();
21-
$node = $doc->appendChild($doc->createElement('root'));
20+
$node = $doc->createElement('a');
2221
for ($i = 0; $i < 100000; $i++) {
23-
$node = $node->appendChild($doc->createElement('a'));
22+
$parent = $doc->createElement('a');
23+
$parent->appendChild($node);
24+
$node = $parent;
2425
}
26+
$doc->appendChild($node);
2527

2628
try {
2729
$doc->saveXml();

0 commit comments

Comments
 (0)