Re: com php-src: Fixed bug #72888 (Segfault on clone on splFileObject): NEWS ext/spl/spl_directory.c ext/spl/tests/bug72888.phpt

From: Date: Sat, 20 Aug 2016 04:44:50 +0000
Subject: Re: com php-src: Fixed bug #72888 (Segfault on clone on splFileObject): NEWS ext/spl/spl_directory.c ext/spl/tests/bug72888.phpt
References: 1 2  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-94011@lists.php.net to get a copy of this message
Hey: On Fri, Aug 19, 2016 at 6:34 PM, Nikita Popov <nikita.ppv@gmail.com> wrote: > On Fri, Aug 19, 2016 at 5:28 AM, Xinchen Hui <laruence@php.net> wrote: > >> 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=566d65d >> 222c00210aa67d6b937021c8100f54678 >> >> 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 >> > > > It would be good to support a NULL return value in ZEND_CLONE as well. > Imho this should be valid, creating an object on failure does not make > sense. > > right, I was thinking the same, anyway, I don't see others usage in php-src. (only this one), so I prefer fixed this one thanks Nikita > -- Xinchen Hui @Laruence http://www.laruence.com/

« previous php.cvs (#94011) next »