com php-src: Partial fix for bug #77751: ext/spl/spl_director y.c ext/spl/tests/bug77751.phpt

From: Date: Mon, 18 Mar 2019 10:06:23 +0000
Subject: com php-src: Partial fix for bug #77751: ext/spl/spl_director y.c ext/spl/tests/bug77751.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-105205@lists.php.net to get a copy of this message
Commit: 4f034016289f5a52073bfd012899dd3e202742b5 Author: Nikita Popov <nikita.ppv@gmail.com> Mon, 18 Mar 2019 11:04:25 +0100 Parents: 54bf8c820f4ac2c9204cd09b66fbe99c3db5939b Branches: PHP-7.2 PHP-7.3 PHP-7.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=4f034016289f5a52073bfd012899dd3e202742b5 Log: Partial fix for bug #77751 This avoids the segfault, but it will not make writing to the SplFileObject during output shutdown work. Bugs: https://bugs.php.net/77751 Changed paths: M ext/spl/spl_directory.c A ext/spl/tests/bug77751.phpt Diff: diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index f13a48a..47b3521 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -97,6 +97,7 @@ static void spl_filesystem_object_destroy_object(zend_object *object) /* {{{ */ } else { php_stream_pclose(intern->u.file.stream); } + intern->u.file.stream = NULL; } break; } @@ -127,13 +128,11 @@ static void spl_filesystem_object_free_storage(zend_object *object) /* {{{ */ } break; case SPL_FS_FILE: - if (intern->u.file.stream) { - if (intern->u.file.open_mode) { - efree(intern->u.file.open_mode); - } - if (intern->orig_path) { - efree(intern->orig_path); - } + if (intern->u.file.open_mode) { + efree(intern->u.file.open_mode); + } + if (intern->orig_path) { + efree(intern->orig_path); } spl_filesystem_file_free_line(intern); break; diff --git a/ext/spl/tests/bug77751.phpt b/ext/spl/tests/bug77751.phpt new file mode 100644 index 0000000..23855c6 --- /dev/null +++ b/ext/spl/tests/bug77751..phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #77751: Writing to SplFileObject in ob_start gives segfault +--FILE-- +<?php + +echo "No crash.\n"; + +$logfile = new SplTempFileObject(); +ob_start(function ($buffer) use ($logfile) { + $logfile->fwrite($buffer); + $logfile->fflush(); + return ""; +}); +echo "hmm\n"; + +?> +--EXPECT-- +No crash.

« previous php.cvs (#105205) next »