php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22592 Cascading assignments to strings with curly braces broken
Submitted: 2003-03-07 11:40 UTC Modified: 2003-07-24 15:14 UTC
Votes:20
Avg. Score:4.4 ± 0.9
Reproduced:15 of 16 (93.8%)
Same Version:7 (46.7%)
Same OS:8 (53.3%)
From: matteo at beccati dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 5.0.0b2-dev OS: *
Private report: No CVE-ID: None
 [2003-03-07 11:40 UTC] matteo at beccati dot com
When using cascading assignments to strings and curly braces, to change characters within strings, only the last character is changed to the right value. Other characters become NUL (0x00).

<?
$wrong = $correct = 'abcdef';

$correct{1} = '*';
$correct{3} = '*';
$correct{5} = '*';

// This produces the 
$wrong{1} = $wrong{3} = $wrong{5} = '*';

echo $correct."\n".$wrong."\n\n";
echo urlencode($correct)."\n"."\n".urlencode($wrong)."\n";

?>


The resulting output is:

a*c*e*
ace*

a%2Ac%2Ae%2A
a%00c%00e%2A


I also tested it on a old PHP 4.2.0-dev, and it gives the same result.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-03-07 12:13 UTC] sniper@php.net
Happens also with 4.3.2-dev. (from today)


 [2003-03-10 13:35 UTC] moriyoshi@php.net
Update version
 [2003-06-16 10:44 UTC] stas@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.

Fixed in ZE2. 
 [2003-06-17 10:51 UTC] sniper@php.net
Also fixed in PHP 4.3.3-dev (latest STABLE snapshot..)

 [2003-07-17 17:11 UTC] helly@php.net
Reopen since it leaks now
 [2003-07-18 07:48 UTC] sniper@php.net
Doesn't leak in PHP 4.3.3RC2-dev. (only PHP 5)

 [2003-07-24 15:14 UTC] sniper@php.net
Marcus, report the leak in separate bug report.

 [2009-09-21 13:32 UTC] svn@php.net
Automatic comment from SVN on behalf of dmitry
Revision: http://svn.php.net/viewvc/?view=revision&revision=288525
Log: Fixed tests/lang/bug22592.phpt
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC