php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24834 Memory corruption bug in object destructor
Submitted: 2003-07-28 00:18 UTC Modified: 2003-07-28 09:19 UTC
From: vma1 at abv dot bg Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5CVS-2003-07-28 (dev) OS: Slackware Linux 9.0
Private report: No CVE-ID: None
 [2003-07-28 00:18 UTC] vma1 at abv dot bg
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

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-28 05:06 UTC] sniper@php.net
I can not reproduce this with latest CVS.


 [2003-07-28 09:19 UTC] sniper@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments
to the existing bug instead.

Thank you for your interest in PHP.

second report opened by same user, making this bogus then.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Aug 19 03:01:30 2024 UTC