|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-07-28 05:06 UTC] sniper@php.net
[2003-07-28 09:19 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 27 21:00:01 2025 UTC |
Description: ------------ The following script causes memory corruption when run from the command line like: php -f ./bug.php There are variants of the script that show the bug when run from the web browser, but these scripts are bigger. Even small changes in the sample script hide the bug. Notice that several bytes in the output string get overwritten. Reproduce code: --------------- <? class database { } $a = new database; $b = new database; class broken { public function __construct () { } public function __destruct () { $this->show (array ( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "", "", "", "", "", "", "", "", "", "", "", "", "", "" )); } private function show ($values) { $values_string = ""; foreach ($values as $val) { $values_string .= $val; } printf ("%s\n", $values_string); } } $brk = new broken (); ?> Expected result: ---------------- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Actual result: -------------- aaaaaaaaaaaa???aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa