Skip to content

Commit fa8611c

Browse files
committed
Fixed bug #65136 (RecursiveDirectoryIterator segfault)
1 parent 76866e0 commit fa8611c

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ PHP NEWS
4242
(Damjan Cvetko)
4343

4444
- SPL:
45+
. Fixed bug #65136 (RecursiveDirectoryIterator segfault). (Laruence)
4546
. Fixed bug #61828 (Memleak when calling Directory(Recursive)Iterator
4647
/Spl(Temp)FileObject ctor twice). (Laruence)
4748

ext/spl/spl_directory.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,7 +1510,7 @@ SPL_METHOD(RecursiveDirectoryIterator, hasChildren)
15101510
Returns an iterator for the current entry if it is a directory */
15111511
SPL_METHOD(RecursiveDirectoryIterator, getChildren)
15121512
{
1513-
zval zpath, zflags;
1513+
zval *zpath, *zflags;
15141514
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
15151515
spl_filesystem_object *subdir;
15161516
char slash = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_UNIXPATHS) ? '/' : DEFAULT_SLASH;
@@ -1524,11 +1524,13 @@ SPL_METHOD(RecursiveDirectoryIterator, getChildren)
15241524
if (SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_CURRENT_AS_PATHNAME)) {
15251525
RETURN_STRINGL(intern->file_name, intern->file_name_len, 1);
15261526
} else {
1527-
INIT_PZVAL(&zflags);
1528-
INIT_PZVAL(&zpath);
1529-
ZVAL_LONG(&zflags, intern->flags);
1530-
ZVAL_STRINGL(&zpath, intern->file_name, intern->file_name_len, 0);
1531-
spl_instantiate_arg_ex2(Z_OBJCE_P(getThis()), &return_value, 0, &zpath, &zflags TSRMLS_CC);
1527+
MAKE_STD_ZVAL(zflags);
1528+
MAKE_STD_ZVAL(zpath);
1529+
ZVAL_LONG(zflags, intern->flags);
1530+
ZVAL_STRINGL(zpath, intern->file_name, intern->file_name_len, 1);
1531+
spl_instantiate_arg_ex2(Z_OBJCE_P(getThis()), &return_value, 0, zpath, zflags TSRMLS_CC);
1532+
zval_ptr_dtor(&zpath);
1533+
zval_ptr_dtor(&zflags);
15321534

15331535
subdir = (spl_filesystem_object*)zend_object_store_get_object(return_value TSRMLS_CC);
15341536
if (subdir) {

0 commit comments

Comments
 (0)