]> granicus.if.org Git - php/commitdiff
Fixed bug #72888 (Segfault on clone on splFileObject)
authorXinchen Hui <laruence@gmail.com>
Fri, 19 Aug 2016 03:28:36 +0000 (11:28 +0800)
committerXinchen Hui <laruence@gmail.com>
Fri, 19 Aug 2016 03:28:36 +0000 (11:28 +0800)
NEWS
ext/spl/spl_directory.c
ext/spl/tests/bug72888.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 5e765fe81e8a1d8d9e5ce0d2afdab626bf56a369..79e9398b76a24bb7a11f74bb53b1442730020c2c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -62,6 +62,9 @@ PHP                                                                        NEWS
   . Implemented RFC: Session ID without hashing. (Yasuo)
     https://wiki.php.net/rfc/session-id-without-hashing
 
+- SPL:
+  . Fixed bug #72888 (Segfault on clone on splFileObject). (Laruence)
+
 - SQLite3:
   . Updated to SQLite3 3.14.0. (cmb)
 
index 6c91c2e75d5c08a22d4808936e2fe984d1bdcf5f..67bfda8a3bf23645cf05400d5cf7408dccdf6da6 100644 (file)
@@ -356,7 +356,7 @@ static zend_object *spl_filesystem_object_clone(zval *zobject)
                        break;
                case SPL_FS_FILE:
                        zend_throw_error(NULL, "An object of class %s cannot be cloned", ZSTR_VAL(old_object->ce->name));
-                       return NULL;
+                       return new_object;
        }
 
        intern->file_class = source->file_class;
diff --git a/ext/spl/tests/bug72888.phpt b/ext/spl/tests/bug72888.phpt
new file mode 100644 (file)
index 0000000..7d2fc6d
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+Bug #72888 (Segfault on clone on splFileObject)
+--FILE--
+<?php
+$x = new SplFileObject(__FILE__);
+
+try {
+       $y=clone $x;
+} catch (Error $e) {
+       var_dump($e->getMessage());
+}
+var_dump($y);
+?>
+--EXPECTF--
+string(49) "An object of class SplFileObject cannot be cloned"
+
+Notice: Undefined variable: y in %sbug72888.php on line %d
+NULL