Skip to content

Commit

Permalink
Fixed bug #67359 (Segfault in recursiveDirectoryIterator)
Browse files Browse the repository at this point in the history
  • Loading branch information
laruence committed Jun 1, 2014
1 parent b5d9983 commit 38be99b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ PHP NEWS
(Adam)

- SPL:
. Fixed bug #67359 (Segfault in recursiveDirectoryIterator). (Laruence)
. Fixed bug #67360 (Missing element after ArrayObject::getIterator). (Adam)

?? ??? 2014, PHP 5.4.29
Expand Down
2 changes: 2 additions & 0 deletions ext/spl/spl_directory.c
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,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;
}
}

Expand All @@ -838,6 +839,7 @@ SPL_METHOD(DirectoryIterator, seek)
if (retval) {
valid = zend_is_true(retval);
zval_ptr_dtor(&retval);
retval = NULL;
}
if (!valid) {
break;
Expand Down
2 changes: 2 additions & 0 deletions ext/spl/spl_iterators.c
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,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, key TSRMLS_CC);
}
} else {
*object_ptr = zobj;
}
}
return function_handler;
Expand Down
28 changes: 28 additions & 0 deletions ext/spl/tests/bug67359.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
--TEST--
Bug #67359 (Segfault in recursiveDirectoryIterator)
--FILE--
<?php
try
{
$rdi = new recursiveDirectoryIterator(dirname(__FILE__), FilesystemIterator::SKIP_DOTS | FilesystemIterator::UNIX_PATHS);
$it = new recursiveIteratorIterator( $rdi );
$it->seek(1);
while( $it->valid())
{
if( $it->isFile() )
{
$it->current();
}

$it->next();
}

$it->current();
}
catch(Exception $e)
{
}
echo "okey"
?>
--EXPECTF--
okey

0 comments on commit 38be99b

Please sign in to comment.