]> granicus.if.org Git - php/commitdiff
- Bugfix #36941 (ArrayIterator does not clone itself)
authorMarcus Boerger <helly@php.net>
Sat, 1 Apr 2006 22:39:42 +0000 (22:39 +0000)
committerMarcus Boerger <helly@php.net>
Sat, 1 Apr 2006 22:39:42 +0000 (22:39 +0000)
ext/spl/spl_array.c
ext/spl/tests/bug36941.phpt [new file with mode: 0755]

index 80b70dedbfaa064dfa59d79db8f173b68eec87e9..b8d2217cf0b42c95eaafe9b3825713356fcaee7a 100755 (executable)
@@ -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;
 
diff --git a/ext/spl/tests/bug36941.phpt b/ext/spl/tests/bug36941.phpt
new file mode 100755 (executable)
index 0000000..737ff82
--- /dev/null
@@ -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===