mirror of
https://github.com/php/php-src.git
synced 2026-03-24 08:12:21 +01:00
Fixed bug #79468
Close the stream filter resources when removing them from the stream.
This commit is contained in:
4
NEWS
4
NEWS
@@ -14,6 +14,10 @@ PHP NEWS
|
||||
. Fixed bug #79441 (Segfault in mb_chr() if internal encoding is unsupported).
|
||||
(Girgias)
|
||||
|
||||
- Standard:
|
||||
. Fixed bug #79468 (SIGSEGV when closing stream handle with a stream filter
|
||||
appended). (dinosaur)
|
||||
|
||||
16 Apr 2020, PHP 7.3.17
|
||||
|
||||
- Core:
|
||||
|
||||
21
ext/standard/tests/filters/bug79468.phpt
Normal file
21
ext/standard/tests/filters/bug79468.phpt
Normal 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());
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: stream_filter_remove(): Invalid resource given, not a stream filter in %s on line %d
|
||||
@@ -476,9 +476,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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user