summaryrefslogtreecommitdiff
path: root/ext/standard
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2016-11-28 12:54:47 +0300
committerDmitry Stogov <dmitry@zend.com>2016-11-28 12:54:47 +0300
commit9a9ad56af0f80c69d363e8cfabe412da798c497d (patch)
tree58baa0d09b318fd5ab0595c16e7dd0c4c64553b2 /ext/standard
parent970f21be97980a18153f13d653f4132cce676158 (diff)
downloadphp-git-9a9ad56af0f80c69d363e8cfabe412da798c497d.tar.gz
Fixed bug #73586 (php_user_filter::$stream is not set to the stream the filter is working on).
Diffstat (limited to 'ext/standard')
-rw-r--r--ext/standard/tests/filters/bug73586.phpt45
-rw-r--r--ext/standard/user_filters.c2
2 files changed, 46 insertions, 1 deletions
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 */