bug21478.phpt 895 B

1234567891011121314151617181920212223242526272829303132
  1. --TEST--
  2. Bug #21478 (Zend/zend_alloc.c :: shutdown_memory_manager produces segfault)
  3. --FILE--
  4. <?php
  5. class debugfilter extends php_user_filter {
  6. function filter($in, $out, &$consumed, $closing): int {
  7. while ($bucket = stream_bucket_make_writeable($in)) {
  8. $bucket->data = strtoupper($bucket->data);
  9. stream_bucket_append($out, $bucket);
  10. $consumed += strlen($bucket->data);
  11. }
  12. return PSFS_PASS_ON;
  13. }
  14. }
  15. stream_filter_register("myfilter","debugfilter");
  16. $fp = fopen(__DIR__."/test.txt","w");
  17. stream_filter_append($fp, "myfilter");
  18. stream_filter_append($fp, "myfilter");
  19. stream_filter_append($fp, "myfilter");
  20. fwrite($fp, "This is a test.\n");
  21. print "Done.\n";
  22. fclose($fp);
  23. // Uncommenting the following 'print' line causes the segfault to stop occurring
  24. // print "2\n";
  25. readfile(__DIR__."/test.txt");
  26. unlink(__DIR__."/test.txt");
  27. ?>
  28. --EXPECT--
  29. Done.
  30. THIS IS A TEST.