#35239 [Asn->Csd]: Objects can lose references
| From: | dmitry@php.net | Date: | Wed, 16 Nov 2005 12:28:41 +0000 |
| Subject: | #35239 [Asn->Csd]: Objects can lose references | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-88269@lists.php.net to get a copy of this message | ||
ID: 35239
Updated by: dmitry@php.net
Reported By: dmitry@php.net
-Status: Assigned
+Status: Closed
Bug Type: Scripting Engine problem
Operating System: *
PHP Version: 6CVS-2005-11-16 (CVS)
Assigned To: dmitry
New Comment:
Fixed in CVS HEAD, PHP_5_1 and PHP_5_0.
Previous Comments:
------------------------------------------------------------------------
[2005-11-16 12:05:22] dmitry@php.net
Description:
------------
Assignment by reference to property may lose reference.
Reproduce code:
---------------
<?php
$a = new stdClass;
$a->x0 = new stdClass;
$a->x0->y0 = 'a';
$a->x0->y1 =& $a->x0;
$a->x0->y2 =& $a->x0;
$a->x0->y0 = 'b';
var_dump($a);
?>
Expected result:
----------------
object(stdClass)#1 (1) {
["x0"]=>
&object(stdClass)#2 (3) {
["y0"]=>
string(1) "b"
["y1"]=>
&object(stdClass)#2 (3) {
["y0"]=>
string(1) "b"
["y1"]=>
*RECURSION*
["y2"]=>
*RECURSION*
}
["y2"]=>
&object(stdClass)#2 (3) {
["y0"]=>
string(1) "b"
["y1"]=>
*RECURSION*
["y2"]=>
*RECURSION*
}
}
}
Actual result:
--------------
object(stdClass)#1 (1) {
["x0"]=>
object(stdClass)#2 (3) {
["y0"]=>
string(1) "b"
["y1"]=>
object(stdClass)#2 (3) {
["y0"]=>
string(1) "b"
["y1"]=>
*RECURSION*
["y2"]=>
*RECURSION*
}
["y2"]=>
object(stdClass)#2 (3) {
["y0"]=>
string(1) "b"
["y1"]=>
*RECURSION*
["y2"]=>
*RECURSION*
}
}
}
/home/dmitry/php/php5.1/Zend/zend_vm_execute.h(393) : Freeing
0x08B29C94 (16 bytes), script=ass4.php
=== Total 1 memory leaks detected ===
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35239&edit=1