php-src/Zend/tests/foreach_by_ref_to_property.phpt
Nikita Popov 36f5d719f5 Fix leak on foreach by ref assign to property
In this case we ended up creating an ASSIGN_OBJ_REF with VAR
result operand, which was not freed.

Fix this by implementing assign_ref_znode the same was as
assign_znode, i.e. performing an assignment with result and
then freeing the result, which will result mark the result as
UNUSED. This is more robust than the special handling for
result == NULL that was used before.

This fixes one of the issues reported in bug #81190.
2021-07-01 15:48:39 +02:00

12 lines
163 B
PHP

--TEST--
Foreach by ref assignment to property
--FILE--
<?php
$obj = new stdClass;
foreach ([0] as &$obj->prop) {
var_dump($obj->prop);
}
?>
--EXPECT--
int(0)