PHP :: Bug #54358 :: Closure, use and reference
| Bug #54358 | Closure, use and reference | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2011-03-23 10:56 UTC | Modified: | 2011-04-08 12:02 UTC |
|
||||||||||
| From: | frederic dot hardy at mageekbox dot net | Assigned: | dmitry (profile) | |||||||||||
| Status: | Closed | Package: | Scripting Engine problem | |||||||||||
| PHP Version: | 5.3.6 | OS: | ||||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2011-03-23 10:56 UTC] frederic dot hardy at mageekbox dot net
Description: ------------ When the same variable is 'used' by one closure by reference, and an another closure 'uses' the same variable by value several time, the variable value is corrupted. This bub seems to be related to http://bugs.php.net/53958 which is closed since PHP 5.3.6. Test script: --------------- <?php class asserter { public function call($function) {} } $asserter = new asserter(); $closure = function() use ($asserter, & $function) { $asserter->call($function = uniqid()); }; try { $closure(); } catch (\exception $exception) { } var_dump($function); $function = 'md5'; $closure = function() use ($asserter, $function) { $asserter->call($function); }; try { $closure(); } catch (\exception $exception) { } var_dump($function); $closure = function() use ($asserter, $function) { $asserter->call($function); }; try { $closure(); } catch (\exception $exception) {} var_dump($function); ?> Expected result: ---------------- string(13) "4d89c1bc241ff" string(3) "md5" string(3) "md5" Actual result: -------------- string(13) "4d89c1bc241ff" string(3) "md5" string(3) �a"
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2011-03-23 11:03 UTC] frederic dot hardy at mageekbox dot net
[2011-03-23 12:45 UTC] pajoye@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: dmitry
[2011-04-08 12:02 UTC] dmitry@php.net
-Status: Assigned +Status: Closed
[2011-04-08 12:02 UTC] dmitry@php.net