diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 80b70dedbfa..b8d2217cf0b 100755 --- a/ext/spl/spl_array.c +++ b/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; diff --git a/ext/spl/tests/bug36941.phpt b/ext/spl/tests/bug36941.phpt new file mode 100755 index 00000000000..737ff828b2f --- /dev/null +++ b/ext/spl/tests/bug36941.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #36941 (ArrayIterator does not clone itself) +--FILE-- + +===DONE=== +--EXPECT-- +int(1) +int(1) +int(1) +int(2) +int(1) +int(3) +===DONE===