summaryrefslogtreecommitdiff
path: root/Zend/tests/bug21478.phpt
blob: 8da198040036c5991c86c9f0583c1235f03bb56a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
--TEST--
Bug #21478 (Zend/zend_alloc.c :: shutdown_memory_manager produces segfault)
--FILE--
<?php
class debugfilter extends php_user_filter {
  function filter($in, $out, &$consumed, $closing) {
    while ($bucket = stream_bucket_make_writeable($in)) {
      $bucket->data = strtoupper($bucket->data);
      stream_bucket_append($out, $bucket);
      $consumed += strlen($bucket->data);
    }
    return PSFS_PASS_ON;
  }
}

stream_filter_register("myfilter","debugfilter");

$fp = fopen(dirname(__FILE__)."/test.txt","w");
stream_filter_append($fp, "myfilter");
stream_filter_append($fp, "myfilter");
stream_filter_append($fp, "myfilter");
fwrite($fp, "This is a test.\n");
print "Done.\n";
fclose($fp);
// Uncommenting the following 'print' line causes the segfault to stop occurring
// print "2\n";
readfile(dirname(__FILE__)."/test.txt");
unlink(dirname(__FILE__)."/test.txt");
?>
--EXPECT--
Done.
THIS IS A TEST.