Merge branch 'PHP-7.4'

* PHP-7.4:
  Fixed bug #79468
This commit is contained in:
Nikita Popov 2020-04-14 12:02:04 +02:00
commit 56d30bb35a
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,21 @@
--TEST--
Bug #79468 SIGSEGV when closing stream handle with a stream filter appended
--SKIPIF--
<?php
$filters = stream_get_filters();
if(! in_array( "string.rot13", $filters )) die( "skip rot13 filter not available." );
?>
--FILE--
<?php
$fp = fopen('php://temp', 'rb');
$rot13_filter = stream_filter_append($fp, "string.rot13", STREAM_FILTER_WRITE);
fwrite($fp, "This is ");
fclose($fp);
try {
stream_filter_remove($rot13_filter);
} catch (\Throwable $e) {
var_dump($e->getMessage());
}
?>
--EXPECT--
string(79) "stream_filter_remove(): supplied resource is not a valid stream filter resource"

View File

@ -485,9 +485,15 @@ fprintf(stderr, "stream_free: %s:%p[%s] preserve_handle=%d release_cast=%d remov
if (close_options & PHP_STREAM_FREE_RELEASE_STREAM) {
while (stream->readfilters.head) {
if (stream->readfilters.head->res != NULL) {
zend_list_close(stream->readfilters.head->res);
}
php_stream_filter_remove(stream->readfilters.head, 1);
}
while (stream->writefilters.head) {
if (stream->writefilters.head->res != NULL) {
zend_list_close(stream->writefilters.head->res);
}
php_stream_filter_remove(stream->writefilters.head, 1);
}