|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-11-15 20:11 UTC] felipe@php.net
-Status: Open
+Status: Closed
-Package: Variables related
+Package: Scripting Engine problem
-Assigned To:
+Assigned To: felipe
[2011-11-15 20:11 UTC] felipe@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 29 18:00:01 2025 UTC |
Description: ------------ This is a bug in 5.3.6, which did not occur in 5.3.5. When executing a Closure, and using a variable which references a string property of the context class, the original string property becomes corrupted. Its first characters become corrupted, resulting in an unexpected new string. (Tested on several CentOS machines; 5.3.6 results in the bug, 5.3.5 does not) Step-by-step recreation: (code sample attached) 1. Define a string property in a class. 2. Define a Closure which accepts a parameter. 3. Execute that Closure, passing a parameter which is a reference to the original string property. 4. The original string property becomes corrupted. If you var_dump() it, you receive a corrupted string instead of your original string. Test script: --------------- class Foo { public function __construct() { $this->a = 'foo'; } public function bug() { $a = &$this->a; $b = function()use($a){ return strlen($a); }; $b(); } } $foo = new Foo(); $foo->bug(); var_dump($foo->a); Expected result: ---------------- String(3) "foo" (this happens in 5.3.5) Actual result: -------------- String(...) "{some_rubbish}oo" (this happens in 5.3.6)