]> granicus.if.org Git - php/commitdiff
Replace the iterator correctly after being cloned (related to #44964)
authorEtienne Kneuss <colder@php.net>
Thu, 15 May 2008 17:22:03 +0000 (17:22 +0000)
committerEtienne Kneuss <colder@php.net>
Thu, 15 May 2008 17:22:03 +0000 (17:22 +0000)
ext/spl/spl_directory.c

index a96a1a31697646702f11ba982822252fa6068fd0..e44a0fe985eb91215fe0f0e75019a967c9eee625 100755 (executable)
@@ -298,6 +298,7 @@ static zend_object_value spl_filesystem_object_clone(zval *zobject TSRMLS_DC)
        zend_object_handle handle = Z_OBJ_HANDLE_P(zobject);
        spl_filesystem_object *intern;
        spl_filesystem_object *source;
+       int index;
 
        old_object = zend_objects_get_address(zobject TSRMLS_CC);
        source = (spl_filesystem_object*)old_object;
@@ -316,6 +317,11 @@ static zend_object_value spl_filesystem_object_clone(zval *zobject TSRMLS_DC)
                break;
        case SPL_FS_DIR:
                spl_filesystem_dir_open(intern, source->_path_type, source->_path, source->_path_len TSRMLS_CC);
+               /* read until we hit the position in which we were before */
+               for(index = 0; index < source->u.dir.index; ++index) {
+                       spl_filesystem_dir_read(intern TSRMLS_CC);
+               }
+               intern->u.dir.index = index;
                break;
        case SPL_FS_FILE:
                php_error_docref(NULL TSRMLS_CC, E_ERROR, "An object of class %v cannot be cloned", old_object->ce->name);