|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-03-10 07:12 UTC] laruence@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: laruence
[2016-03-10 07:12 UTC] laruence@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 14:00:01 2025 UTC |
Description: ------------ Under very certain circumstances a call-by-reference gets out of bounds. A cascaded call of functions, where one of them has a call-by-reference in its parameters, a change to a copy of an hash gets unexpectedly overwritten outside of its scope. Key to this behaviour is the use of the switch-statement in the final function call. Additional Information: - casting the switch-parameter to string solves the problem - changing the switch into an if-statement also solves the problem Test script: --------------- <?php function a ($option) { b($option['bla']); c($option); var_dump($option); } function b (&$string) { $string = 'changed'; } function c ($option) { switch ($option['bla']) { case 'changed': $copy = $option; $copy['bla'] = 'copy'; break; } } a(array('bla' => 'fasel')); Expected result: ---------------- array(1) { ["bla"]=> string(4) "changed" } Actual result: -------------- array(1) { ["bla"]=> string(4) "copy" }