xref: /php-src/ext/standard/tests/file/bug39551.phpt (revision be2f454d)
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+'), '');
7var_dump($bucket);
8
9class bucketFilter extends php_user_filter {
10    public function filter($in, $out, &$consumed, $closing ): int {
11
12        $bucket = stream_bucket_new(fopen('php://temp', 'w+'), '');
13        stream_bucket_append($out, $bucket);
14        return PSFS_PASS_ON;
15    }
16}
17
18stream_filter_register('bucketfault', 'bucketFilter');
19stream_filter_append($s = fopen('php://temp', 'r+'), 'bucketfault');
20stream_get_contents($s);
21
22echo "Done\n";
23?>
24--EXPECTF--
25object(StreamBucket)#%d (%d) {
26  ["bucket"]=>
27  resource(%d) of type (userfilter.bucket)
28  ["data"]=>
29  string(0) ""
30  ["datalen"]=>
31  int(0)
32  ["dataLength"]=>
33  int(0)
34}
35Done
36