PHP 4.0 Bug #6750: passing undefined variables by reference mangles function parameters
| From: | dshadow at zort dot net | Date: | Thu, 14 Sep 2000 06:07:58 +0000 |
| Subject: | PHP 4.0 Bug #6750: passing undefined variables by reference mangles function parameters | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-33258@lists.php.net to get a copy of this message | ||
From: dshadow@zort.net
Operating system: Linux
PHP version: 4.0.2
PHP Bug Type: Scripting Engine problem
Bug description: passing undefined variables by reference mangles function parameters
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);