#33136 [Opn->Fbk]: method offsetSet in class extended from ArrayObject crash PHP

From: Date: Wed, 25 May 2005 22:37:58 +0000
Subject: #33136 [Opn->Fbk]: method offsetSet in class extended from ArrayObject crash PHP
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-79509@lists.php.net to get a copy of this message
 ID:               33136
 Updated by:       sniper@php.net
 Reported By:      nightik at intech dot ru
-Status:           Open
+Status:           Feedback
 Bug Type:         SPL related
 Operating System: Windows XP/2003
 PHP Version:      5.0.4
 New Comment:

Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip




Previous Comments:
------------------------------------------------------------------------

[2005-05-25 13:39:42] nightik at intech dot ru

Description:
------------
method offsetSet in class extended from ArrayObject crash PHP with
message "PHP has encountered an Access Violation at 018CC7A0"
If method offsetSet not present in Collection class it work fine.

Web-server IIS 5.0 on Windows XP and 6.0 on Windows 2003 Server

Reproduce code:
---------------
class Collection extends ArrayObject
{
	private $data;
	
	function __construct()
	{
		$this->data = array();
		parent::__construct( $this->data );
	}
	
	function offsetGet( $index )
	{
		echo "Collection::offsetGet()\n";
		return parent::offsetGet( $index );
	}
	
	function offsetSet( $index, $value )
	{
		echo "Collection::offsetSet()\n";
		parent::offsetSet( $index, $value );
	}
}

echo "\n\nInitiate Obj\n";
$arrayObj = new Collection();

echo "Assign values\n";

$arrayObj[] = "foo";
$arrayObj[] = "bar";
$arrayObj["foo"] = "bar";

echo "Getting values\n";
echo $arrayObj["foo"];

echo "Printing Collection\n";
print_r( $arrayObj );

echo "Count Collection items\n";
echo count( $arrayObj );


Expected result:
----------------
Initiate Obj
Assign values
Collection::offsetSet()
Collection::offsetSet()
Collection::offsetSet()
Getting values
Collection::offsetGet()
bar
Printing Collection
Collection Object
(
    [0] => foo
    [1] => bar
    [foo] => bar
)
Count Collection items
3

Actual result:
--------------
PHP has encountered an Access Violation at 018CC7A0

Initiate Obj
Assign values



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=33136&edit=1


Thread (6 messages)

« previous php.bugs (#79509) next »