com php-src: Fixed bug #72888 (Segfault on clone on splFileObject): NEWS ext/spl/spl_directory.c ext/spl/tests/bug72888 .phpt
| From: | Xinchen Hui | Date: | Fri, 19 Aug 2016 03:28:36 +0000 |
| Subject: | com php-src: Fixed bug #72888 (Segfault on clone on splFileObject): NEWS ext/spl/spl_directory.c ext/spl/tests/bug72888 .phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-93982@lists.php.net to get a copy of this message | ||
Commit: 566d65d222c00210aa67d6b937021c8100f54678
Author: Xinchen Hui <laruence@gmail.com> Fri, 19 Aug 2016 11:28:36 +0800
Parents: 0b1c8178ab7c528909861c1a263ecd03345195a3
Branches: PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=566d65d222c00210aa67d6b937021c8100f54678
Log:
Fixed bug #72888 (Segfault on clone on splFileObject)
Bugs:
https://bugs.php.net/72888
Changed paths:
M NEWS
M ext/spl/spl_directory.c
A ext/spl/tests/bug72888.phpt
Diff:
diff --git a/NEWS b/NEWS
index 5e765fe..79e9398 100644
--- 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)
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index 6c91c2e..67bfda8 100644
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -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
index 0000000..7d2fc6d
--- /dev/null
+++ b/ext/spl/tests/bug72888.phpt
@@ -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