bug38779_1.phpt 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. --TEST--
  2. Bug #38779 (engine crashes when require()'ing file with syntax error through userspace stream wrapper)
  3. --FILE--
  4. <?php
  5. class Loader {
  6. private $position;
  7. private $data;
  8. public function stream_open($path, $mode, $options, &$opened_path) {
  9. $this->data = '<' . "?php \n\"\";ll l\n ?" . '>';
  10. $this->position = 0;
  11. return true;
  12. }
  13. function stream_read($count) {
  14. $ret = substr($this->data, $this->position, $count);
  15. $this->position += strlen($ret);
  16. return $ret;
  17. }
  18. function stream_eof() {
  19. return $this->position >= strlen($this->data);
  20. }
  21. function stream_flush() {
  22. @unlink(dirname(__FILE__)."/bug38779.txt");
  23. var_dump("flush!");
  24. }
  25. function stream_close() {
  26. var_dump("close!");
  27. }
  28. }
  29. stream_wrapper_register('Loader', 'Loader');
  30. $fp = fopen ('Loader://qqq.php', 'r');
  31. $filename = dirname(__FILE__)."/bug38779.txt";
  32. $fp1 = fopen($filename, "w");
  33. fwrite($fp1, "<"."?php blah blah?".">");
  34. fclose($fp1);
  35. include $filename;
  36. echo "Done\n";
  37. ?>
  38. --EXPECTF--
  39. Parse error: %s error%sin %s on line %d
  40. string(6) "flush!"
  41. string(6) "close!"