php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47671 Cloning of SplObjectStorage is undefined
Submitted: 2009-03-16 11:42 UTC Modified: 2009-03-19 02:45 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: robert at typo3 dot org Assigned: colder (profile)
Status: Closed Package: SPL related
PHP Version: 5.3.0beta1 OS: Mac OS 10.5.6
Private report: No CVE-ID: None
 [2009-03-16 11:42 UTC] robert at typo3 dot org
Description:
------------
After cloning an instance of SplObjectStorage the number of objects 
which can be retrieved with count() is very high and foreach() causes a 
segfault.

Reproduce code:
---------------
class Foo {}

$storageA = new \SplObjectStorage();
$storageA->attach(new \Foo);
$storageA->attach(new \Foo);

echo ("Count storage A: " . count($storageA));
foreach ($storageA as $object) {
	echo ' x ';
}

$storageB = clone $storageA;
echo ("Count storage B: " . count($storageB));
foreach ($storageB as $object) {
	echo ' x ';
}


Expected result:
----------------
Count storage A: 2 x x Count storage B: 2 x x

Actual result:
--------------
Count storage A: 2 x x Count storage B: 1953394499

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-03-19 02:45 UTC] colder@php.net
This bug has been fixed in CVS.

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/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC