diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-04-14 12:00:02 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-04-14 12:01:51 +0200 |
commit | ef56b2c977cac5e47e0ba4960b8305078ded87be (patch) | |
tree | 4c4f084d7aa09977bd36c2e655f6c642d317dceb | |
parent | a76b3358e4a81537a667b127f1d6141614223b95 (diff) | |
parent | 95eaccd0bb901495323c36282d4e783556be1964 (diff) | |
download | php-git-ef56b2c977cac5e47e0ba4960b8305078ded87be.tar.gz |
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
Fixed bug #79468
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | ext/standard/tests/filters/bug79468.phpt | 21 | ||||
-rw-r--r-- | main/streams/streams.c | 6 |
3 files changed, 31 insertions, 0 deletions
@@ -17,6 +17,10 @@ PHP NEWS - SPL: . Fixed bug #69264 (__debugInfo() ignored while extending SPL classes). (cmb) +- Standard: + . Fixed bug #79468 (SIGSEGV when closing stream handle with a stream filter + appended). (dinosaur) + ?? ??? ????, PHP 7.4.5 - Core: diff --git a/ext/standard/tests/filters/bug79468.phpt b/ext/standard/tests/filters/bug79468.phpt new file mode 100644 index 0000000000..60a848ec01 --- /dev/null +++ b/ext/standard/tests/filters/bug79468.phpt @@ -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 diff --git a/main/streams/streams.c b/main/streams/streams.c index f269f06f3e..f1f8bf7eab 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -487,9 +487,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); } |