#29423 [Fbk->Opn]: reference count gets wrong when return-reference-calling a normal function
ID: 29423
User updated by: stefan at hotpaenz dot de
Reported By: stefan at hotpaenz dot de
-Status: Feedback
+Status: Open
Bug Type: Zend Engine 2 problem
Operating System: Linux 2.6.3
PHP Version: 5CVS-2004-07-28 (dev)
New Comment:
The bug remains for me with "latest cvs" snapshot
200503070930, configured with
./configure --disable-cli --enable-cgi --without-pear
--disable-all
Previous Comments:
------------------------------------------------------------------------
[2005-03-06 22:12:14] sniper@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
------------------------------------------------------------------------
[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
Thread (7 messages)