diff options
author | Dmitry Stogov <dmitry@zend.com> | 2016-11-28 12:57:02 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2016-11-28 12:57:02 +0300 |
commit | cabcf8971f849ed72562916f7c113608568650c6 (patch) | |
tree | 45799a6e310d3fd2dfb01a76f86ee4363b317e5a | |
parent | 458c732ed4fae4d174da727e6dadf8e014e3c93d (diff) | |
parent | 9a9ad56af0f80c69d363e8cfabe412da798c497d (diff) | |
download | php-git-cabcf8971f849ed72562916f7c113608568650c6.tar.gz |
Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
Fixed bug #73586 (php_user_filter::$stream is not set to the stream the filter is working on).
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | Zend/zend_hash.h | 10 | ||||
-rw-r--r-- | ext/standard/tests/filters/bug73586.phpt | 45 | ||||
-rw-r--r-- | ext/standard/user_filters.c | 2 |
4 files changed, 60 insertions, 1 deletions
@@ -54,6 +54,10 @@ PHP NEWS (rowan dot collins at gmail dot com) . Fixed bug #73303 (Scope not inherited by eval in assert()). (nikic) +- Streams: + . Fixed bug #73586 (php_user_filter::$stream is not set to the stream the + filter is working on). (Dmitry) + - XML: . Fixed bug #72135 (malformed XML causes fault) (edgarsandi) diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h index 190551d3f1..e4f8fd8a91 100644 --- a/Zend/zend_hash.h +++ b/Zend/zend_hash.h @@ -328,6 +328,16 @@ static zend_always_inline zval *zend_hash_str_find_ind(const HashTable *ht, cons } +static zend_always_inline int zend_hash_str_exists_ind(const HashTable *ht, const char *str, size_t len) +{ + zval *zv; + + zv = zend_hash_str_find(ht, str, len); + return zv && (Z_TYPE_P(zv) != IS_INDIRECT || + Z_TYPE_P(Z_INDIRECT_P(zv)) != IS_UNDEF); +} + + static zend_always_inline zval *zend_symtable_update(HashTable *ht, zend_string *key, zval *pData) { zend_ulong idx; diff --git a/ext/standard/tests/filters/bug73586.phpt b/ext/standard/tests/filters/bug73586.phpt new file mode 100644 index 0000000000..3cae4662bf --- /dev/null +++ b/ext/standard/tests/filters/bug73586.phpt @@ -0,0 +1,45 @@ +--TEST-- +Bug #73586 (php_user_filter::$stream is not set to the stream the filter is working on). +--FILE-- +<?php +class append_filter extends php_user_filter { + public $stream; + function filter($in, $out, &$consumed, $closing) { + while ($bucket = stream_bucket_make_writeable($in)) { + $consumed += $bucket->datalen; + stream_bucket_append($out, $bucket); + } + if ($closing) { + $bucket = stream_bucket_new($this->stream, "FooBar\n"); + stream_bucket_append($out, $bucket); + } + return PSFS_PASS_ON; + } +} +stream_filter_register("append", "append_filter"); +$fin = fopen(__FILE__, 'rb'); +stream_filter_append($fin, 'append', STREAM_FILTER_READ); +stream_copy_to_stream($fin, STDOUT); +?> +--EXPECT-- +<?php +class append_filter extends php_user_filter { + public $stream; + function filter($in, $out, &$consumed, $closing) { + while ($bucket = stream_bucket_make_writeable($in)) { + $consumed += $bucket->datalen; + stream_bucket_append($out, $bucket); + } + if ($closing) { + $bucket = stream_bucket_new($this->stream, "FooBar\n"); + stream_bucket_append($out, $bucket); + } + return PSFS_PASS_ON; + } +} +stream_filter_register("append", "append_filter"); +$fin = fopen(__FILE__, 'rb'); +stream_filter_append($fin, 'append', STREAM_FILTER_READ); +stream_copy_to_stream($fin, STDOUT); +?> +FooBar diff --git a/ext/standard/user_filters.c b/ext/standard/user_filters.c index 2da03cd276..19aff782fd 100644 --- a/ext/standard/user_filters.c +++ b/ext/standard/user_filters.c @@ -175,7 +175,7 @@ php_stream_filter_status_t userfilter_filter( return ret; } - if (!zend_hash_str_exists(Z_OBJPROP_P(obj), "stream", sizeof("stream")-1)) { + if (!zend_hash_str_exists_ind(Z_OBJPROP_P(obj), "stream", sizeof("stream")-1)) { zval tmp; /* Give the userfilter class a hook back to the stream */ |