Skip to content

Commit 2c540ab

Browse files
committed
adding test
1 parent d8862f9 commit 2c540ab

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

Zend/tests/gh18519.phpt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--TEST--
2+
GH-18519: Nested object comparison leading to stack overflow
3+
--FILE--
4+
<?php
5+
6+
class Node {
7+
public $next;
8+
// forcing dynamic property creation is key
9+
}
10+
11+
$first = new Node();
12+
$first->previous = $first;
13+
$first->next = $first;
14+
15+
$cur = $first;
16+
17+
for ($i = 0; $i < 50000; $i++) {
18+
$new = new Node();
19+
$new->previous = $cur;
20+
$cur->next = $new;
21+
$new->next = $first;
22+
$first->previous = $new;
23+
$cur = $new;
24+
}
25+
26+
try {
27+
// Force comparison manually to trigger zend_hash_compare
28+
$first == $cur;
29+
} catch(Error $e) {
30+
echo $e->getMessage(). PHP_EOL;
31+
}
32+
?>
33+
--EXPECT--
34+
Object compare - stack limit reached

0 commit comments

Comments
 (0)