#29423 [Opn->Ver]: reference count gets wrong when return-reference-calling a normal function

From: Date: Sun, 08 Aug 2004 13:45:44 +0000
Subject: #29423 [Opn->Ver]: reference count gets wrong when return-reference-calling a normal function
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-64259@lists.php.net to get a copy of this message
ID: 29423 Updated by: magnus@php.net Reported By: stefan at hotpaenz dot de -Status: Open +Status: Verified Bug Type: Zend Engine 2 problem Operating System: Linux 2.6.3 PHP Version: 5CVS-2004-07-28 (dev) Previous Comments: ------------------------------------------------------------------------ [2004-07-28 10:59:58] stefan at hotpaenz dot de Description: ------------ See the code below: An object of ClassA is passed to FuncB, which calls FuncA with the return-by-reference operator. FuncA is not designed to return by reference. The reference count seems to get wrong by doing that so the object is discarded when FuncB returns. Reproduce code: --------------- <?php class ClassA { } function FuncA($obj) { return $obj; } function FuncB($obj) { $dummy = &FuncA($obj); } $obj = new ClassA(); FuncB($obj); $str='This is a string' var_dump($obj); Expected result: ---------------- object(ClassA)#1 (0) { } Actual result: -------------- string(16) "This is a string" ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=29423&edit=1

« previous php.bugs (#64259) next »