php-src/Zend/tests/unset_prop_recursion.phpt
Nikita Popov ebd3a21002 Undef slot before destroying in unset_property
We need to make sure that destructors can't access the partially
destroyed property. Do the same we do in HTs.

Fixes oss-fuzz #36205.
2021-07-15 09:31:19 +02:00

66 lines
1007 B
PHP

--TEST--
Unset property where unset will recursively access property again
--FILE--
<?php
class Node {
public $parent = null;
public $children = [];
function insert(Node $node) {
$node->parent = $this;
$this->children[] = $node;
}
function __destruct() {
var_dump($this);
unset($this->children);
}
}
$a = new Node;
$a->insert(new Node);
$a->insert(new Node);
?>
--EXPECT--
object(Node)#1 (2) {
["parent"]=>
NULL
["children"]=>
array(2) {
[0]=>
object(Node)#2 (2) {
["parent"]=>
*RECURSION*
["children"]=>
array(0) {
}
}
[1]=>
object(Node)#3 (2) {
["parent"]=>
*RECURSION*
["children"]=>
array(0) {
}
}
}
}
object(Node)#2 (2) {
["parent"]=>
object(Node)#1 (2) {
["parent"]=>
NULL
}
["children"]=>
array(0) {
}
}
object(Node)#3 (2) {
["parent"]=>
object(Node)#1 (2) {
["parent"]=>
NULL
}
["children"]=>
array(0) {
}
}