diff options
author | Xinchen Hui <laruence@gmail.com> | 2016-08-19 11:28:36 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@gmail.com> | 2016-08-19 11:28:36 +0800 |
commit | 566d65d222c00210aa67d6b937021c8100f54678 (patch) | |
tree | e8f0c2e3c4f37338c2dd4c112d8f505e99fdcf85 | |
parent | 0b1c8178ab7c528909861c1a263ecd03345195a3 (diff) | |
download | php-git-566d65d222c00210aa67d6b937021c8100f54678.tar.gz |
Fixed bug #72888 (Segfault on clone on splFileObject)
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | ext/spl/spl_directory.c | 2 | ||||
-rw-r--r-- | ext/spl/tests/bug72888.phpt | 18 |
3 files changed, 22 insertions, 1 deletions
@@ -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 6c91c2e75d..67bfda8a3b 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 0000000000..7d2fc6db08 --- /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 |