summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-03-18 11:07:27 +0100
committerNikita Popov <nikita.ppv@gmail.com>2019-03-18 11:07:27 +0100
commit82fbaab53c4ea6fb8417cbad8254b8475e50b4cd (patch)
tree4b45cf860ee807ff33721104451717361d99f6bf
parentda7add3525d78181f15dcabc4025d5a972e23b57 (diff)
parent4f034016289f5a52073bfd012899dd3e202742b5 (diff)
downloadphp-git-82fbaab53c4ea6fb8417cbad8254b8475e50b4cd.tar.gz
Merge branch 'PHP-7.2' into PHP-7.3
-rw-r--r--ext/spl/spl_directory.c13
-rw-r--r--ext/spl/tests/bug77751.phpt18
2 files changed, 24 insertions, 7 deletions
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index 946e1cde7d..7f14ae987c 100644
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -95,6 +95,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;
default:
@@ -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 0000000000..23855c6f1b
--- /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.