Browse Source

- Bugfix #36941 (ArrayIterator does not clone itself)

migration/RELEASE_1_0_0
Marcus Boerger 20 years ago
parent
commit
ac099ca676
  1. 1
      ext/spl/spl_array.c
  2. 24
      ext/spl/tests/bug36941.phpt

1
ext/spl/spl_array.c

@ -228,6 +228,7 @@ static zend_object_value spl_array_object_clone(zval *zobject TSRMLS_DC)
spl_array_object *intern;
old_object = zend_objects_get_address(zobject TSRMLS_CC);
SEPARATE_ZVAL(&zobject);
new_obj_val = spl_array_object_new_ex(old_object->ce, &intern, zobject TSRMLS_CC);
new_object = &intern->std;

24
ext/spl/tests/bug36941.phpt

@ -0,0 +1,24 @@
--TEST--
Bug #36941 (ArrayIterator does not clone itself)
--FILE--
<?php
$a = new ArrayIterator();
$a[] = 1;
$b = clone $a;
var_dump($a[0], $b[0]);
$b[0] = $b[0] + 1;
var_dump($a[0], $b[0]);
$b[0] = 3;
var_dump($a[0], $b[0]);
?>
===DONE===
--EXPECT--
int(1)
int(1)
int(1)
int(2)
int(1)
int(3)
===DONE===
Loading…
Cancel
Save