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