From: Xinchen Hui Date: Sun, 1 Jun 2014 11:41:01 +0000 (+0800) Subject: Fixed bug #67359 (Segfault in recursiveDirectoryIterator) X-Git-Tag: php-5.3.29RC1~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b5051ff939eb9dbada8ce10fbea8cf37e50b5a36;p=php Fixed bug #67359 (Segfault in recursiveDirectoryIterator) --- diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 13af7815c5..149db9ab81 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -819,6 +819,7 @@ SPL_METHOD(DirectoryIterator, seek) zend_call_method_with_0_params(&this_ptr, Z_OBJCE_P(getThis()), &intern->u.dir.func_rewind, "rewind", &retval); if (retval) { zval_ptr_dtor(&retval); + retval = NULL; } } @@ -828,6 +829,7 @@ SPL_METHOD(DirectoryIterator, seek) if (retval) { valid = zend_is_true(retval); zval_ptr_dtor(&retval); + retval = NULL; } if (!valid) { break; diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index cd0af8fbc5..d83f450752 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -858,6 +858,8 @@ static union _zend_function *spl_recursive_it_get_method(zval **object_ptr, char *object_ptr = zobj; function_handler = Z_OBJ_HT_P(*object_ptr)->get_method(object_ptr, method, method_len TSRMLS_CC); } + } else { + *object_ptr = zobj; } } return function_handler; diff --git a/ext/spl/tests/bug67359.phpt b/ext/spl/tests/bug67359.phpt new file mode 100644 index 0000000000..e2e61133f3 --- /dev/null +++ b/ext/spl/tests/bug67359.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #67359 (Segfault in recursiveDirectoryIterator) +--FILE-- +seek(1); + while( $it->valid()) + { + if( $it->isFile() ) + { + $it->current(); + } + + $it->next(); + } + + $it->current(); +} +catch(Exception $e) +{ +} +echo "okey" +?> +--EXPECTF-- +okey