xref: /PHP-8.3/ext/standard/tests/file/bug39551.phpt (revision 902d6439)
1--TEST--
2Bug #39551 (Segfault with stream_bucket_new in user filter)
3--FILE--
4<?php
5
6$bucket = stream_bucket_new(fopen('php://temp', 'w+'), '');
7
8class bucketFilter extends php_user_filter {
9    public function filter($in, $out, &$consumed, $closing ): int {
10
11        $bucket = stream_bucket_new(fopen('php://temp', 'w+'), '');
12        stream_bucket_append($out, $bucket);
13        return PSFS_PASS_ON;
14    }
15}
16
17stream_filter_register('bucketfault', 'bucketFilter');
18stream_filter_append($s = fopen('php://temp', 'r+'), 'bucketfault');
19stream_get_contents($s);
20
21echo "Done\n";
22?>
23--EXPECT--
24Done
25