xref: /PHP-7.2/Zend/tests/bug21478.phpt (revision 17ccbeec)
1--TEST--
2Bug #21478 (Zend/zend_alloc.c :: shutdown_memory_manager produces segfault)
3--SKIPIF--
4<?php
5	if (!function_exists('stream_filter_register')) die('skip stream_filter_register() not available');
6?>
7--FILE--
8<?php
9class debugfilter extends php_user_filter {
10  function filter($in, $out, &$consumed, $closing) {
11    while ($bucket = stream_bucket_make_writeable($in)) {
12      $bucket->data = strtoupper($bucket->data);
13      stream_bucket_append($out, $bucket);
14      $consumed += strlen($bucket->data);
15    }
16    return PSFS_PASS_ON;
17  }
18}
19
20stream_filter_register("myfilter","debugfilter");
21
22$fp = fopen(dirname(__FILE__)."/test.txt","w");
23stream_filter_append($fp, "myfilter");
24stream_filter_append($fp, "myfilter");
25stream_filter_append($fp, "myfilter");
26fwrite($fp, "This is a test.\n");
27print "Done.\n";
28fclose($fp);
29// Uncommenting the following 'print' line causes the segfault to stop occurring
30// print "2\n";
31readfile(dirname(__FILE__)."/test.txt");
32unlink(dirname(__FILE__)."/test.txt");
33?>
34--EXPECT--
35Done.
36THIS IS A TEST.
37