PHP 4.0 Bug #6750 Updated: passing undefined variables by reference mangles function parameters

From: Date: Sat, 16 Dec 2000 18:49:46 +0000
Subject: PHP 4.0 Bug #6750 Updated: passing undefined variables by reference mangles function parameters
Groups: php.dev 
Request: Send a blank email to php-dev+get-41604@lists.php.net to get a copy of this message
ID: 6750 Updated by: waldschrott Reported By: dshadow@zort.net Old-Status: Analyzed Status: Closed Bug Type: Scripting Engine problem Assigned To: Comments: this if fixed now, it was related to some undefined behaviour using references and function calls Previous Comments: --------------------------------------------------------------------------- [2000-09-14 03:09:43] waldschrott@php.net argh, this is really bad, what seems to happen is (verified with modified tests): if a non-existent variable (NULL works) is passed to the referenced parameter, *all* other parameters are overwritten with the value of the precessing variable the referenced one too, what explains the current buggy behaviour at the third function call --------------------------------------------------------------------------- [2000-09-14 02:07:58] dshadow@zort.net Passing an undefined variable or function result to a function expecting said parameter by reference mangles the function parameters. The following script results in this output: SomeFunc(2, 2, 2) //this is really bad SomeFunc(1, 2, 1) //This is correct SomeFunc(1, 2, 2) //This isn't correct, but it's not good either This bug is in PHP 4.0.2 and the 4.0.3 CVS. The earliest version I know of with the problem is a 4.0.2 CVS with a build date of Jul 21, so the problem has existed since at least then. --- function returnUndef() { return $foo; } function returnDef() { return 1; } function SomeFunc($a, $b, &$c) { echo("SomeFunc($a, $b, $c)n"); } SomeFunc(1, 2, returnUndef()); SomeFunc(1, 2, returnDef()); SomeFunc(1, 2, $bar); --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=6750

« previous php.dev (#41604) next »