]> granicus.if.org Git - php/commitdiff
Fixed bug #67359 (Segfault in recursiveDirectoryIterator)
authorXinchen Hui <laruence@php.net>
Sun, 1 Jun 2014 11:41:01 +0000 (19:41 +0800)
committerXinchen Hui <laruence@php.net>
Sun, 1 Jun 2014 11:41:01 +0000 (19:41 +0800)
NEWS
ext/spl/spl_directory.c
ext/spl/spl_iterators.c
ext/spl/tests/bug67359.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 354a796af2bcd05403aa2fb47a82ad520ded1dbb..04058b61a8f1609d72bc7bfa3da6685281dc9d87 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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
index 0762db6259f8e293c476038f937ee740338fc563..8cd352f0bfc0a6c676cd6bd3b6d47bfb1f40625a 100644 (file)
@@ -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;
                }
        }
 
@@ -838,6 +839,7 @@ SPL_METHOD(DirectoryIterator, seek)
                if (retval) {
                        valid = zend_is_true(retval);
                        zval_ptr_dtor(&retval);
+                       retval = NULL;
                }
                if (!valid) {
                        break;
index f3120b2013e2297ae7ce2c51118c1588ed4ceb88..fd2e472f05a74a7b0045a91df9d43d5bc8a9a460 100644 (file)
@@ -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;
diff --git a/ext/spl/tests/bug67359.phpt b/ext/spl/tests/bug67359.phpt
new file mode 100644 (file)
index 0000000..e2e6113
--- /dev/null
@@ -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