]> 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)
committerStanislav Malyshev <stas@php.net>
Fri, 18 Jul 2014 23:28:58 +0000 (16:28 -0700)
ext/spl/spl_directory.c
ext/spl/spl_iterators.c
ext/spl/tests/bug67359.phpt [new file with mode: 0644]

index 13af7815c5468f9f134d7054021ca9c667360e6b..149db9ab8126d1ef86aa28bfa75d8963065c51ec 100644 (file)
@@ -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;
index cd0af8fbc5296e264506966d9df510cca908416f..d83f45075206168a3d29c412594bb5896e38047d 100644 (file)
@@ -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 (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