ID: 20739 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -Status: Open +Status: Verified Bug Type: Unknown/Other Function -Operating System: Win2k +Operating System: All -PHP Version: 4.2.3 +PHP Version: 4.3.0-dev/4.4.0-dev New Comment:
In addition to returning the wrong value the code produces a number of memory leaks that are listed below. /home/rei/PHP_CVS/php4/Zend/zend_execute.c(468) : Freeing 0x084F7E24 (12 bytes), script=r.php /home/rei/PHP_CVS/php4/Zend/zend_hash.c(262) : Freeing 0x084F7DCC (40 bytes), script=r.php Last leak repeated 1 time /home/rei/PHP_CVS/php4/Zend/zend_hash.c(178) : Freeing 0x084FCBF4 (32 bytes), script=r.php Last leak repeated 1 time /home/rei/PHP_CVS/php4/Zend/zend_execute.c(1692) : Freeing 0x084FCB94 (44 bytes), script=r.php /home/rei/PHP_CVS/php4/Zend/zend_variables.c(135) : Actual location (location was relayed) Last leak repeated 1 time /home/rei/PHP_CVS/php4/Zend/zend_execute.c(471) : Freeing 0x084F96FC (4 bytes), script=r.php /home/rei/PHP_CVS/php4/Zend/zend_variables.c(111) : Actual location (location was relayed) /home/rei/PHP_CVS/php4/Zend/zend_execute.c(479) : Freeing 0x084F96BC (12 bytes), script=r.php /home/rei/PHP_CVS/php4/Zend/zend_execute.c(1986) : Freeing 0x084F960C (44 bytes), script=r.php /home/rei/PHP_CVS/php4/Zend/zend_API.c(565) : Actual location (location was relayed) Previous Comments: ------------------------------------------------------------------------ [2002-11-30 15:37:53] [EMAIL PROTECTED] I'm using PHP 4.2.3 on Windows NT 5.0 build 2195 (win2k) along with Apache and stumbled across a strange behaviour regarding return() arguments in parentheses. Consider the following code: class Node { var $children; var $name; function Node($name) { $this->children = array(); $this->name = $name; } function &add($n) { $this->children[0] = $n; return($this->children[0]); # these () make a difference } } $t = new Node("top"); $node = new Node("foo"); $n = &$t->add($node); $n->name = "bar"; print $n->name; # output: "bar" print $t->children[0]->name; # output: "foo" The code is working as expected (i.e., both times "bar" is printed) when you remove the parentheses from the return call in the add method. According to the manual, parentheses in a return call shouldn't make a difference. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=20739&edit=1