bug32647.phpt 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. --TEST--
  2. Bug #32647 (Using register_shutdown_function() with invalid callback can crash PHP)
  3. --FILE--
  4. <?php
  5. function foo()
  6. {
  7. echo "foo!\n";
  8. }
  9. class bar
  10. {
  11. function barfoo ()
  12. { echo "bar!\n"; }
  13. }
  14. unset($obj);
  15. try {
  16. register_shutdown_function(array($obj,""));
  17. } catch (TypeError $exception) {
  18. echo $exception->getMessage() . "\n";
  19. }
  20. try {
  21. register_shutdown_function(array($obj,"some string"));
  22. } catch (TypeError $exception) {
  23. echo $exception->getMessage() . "\n";
  24. }
  25. try {
  26. register_shutdown_function(array(0,""));
  27. } catch (TypeError $exception) {
  28. echo $exception->getMessage() . "\n";
  29. }
  30. try {
  31. register_shutdown_function(array('bar','foo'));
  32. } catch (TypeError $exception) {
  33. echo $exception->getMessage() . "\n";
  34. }
  35. try {
  36. register_shutdown_function(array(0,"some string"));
  37. } catch (TypeError $exception) {
  38. echo $exception->getMessage() . "\n";
  39. }
  40. try {
  41. register_shutdown_function('bar');
  42. } catch (TypeError $exception) {
  43. echo $exception->getMessage() . "\n";
  44. }
  45. register_shutdown_function('foo');
  46. try {
  47. register_shutdown_function(array('bar','barfoo'));
  48. } catch (TypeError $exception) {
  49. echo $exception->getMessage() . "\n";
  50. }
  51. $obj = new bar;
  52. try {
  53. register_shutdown_function(array($obj,'foobar'));
  54. } catch (TypeError $exception) {
  55. echo $exception->getMessage() . "\n";
  56. }
  57. register_shutdown_function(array($obj,'barfoo'));
  58. ?>
  59. --EXPECTF--
  60. Warning: Undefined variable $obj in %s on line %d
  61. register_shutdown_function(): Argument #1 ($callback) must be a valid callback, first array member is not a valid class name or object
  62. Warning: Undefined variable $obj in %s on line %d
  63. register_shutdown_function(): Argument #1 ($callback) must be a valid callback, first array member is not a valid class name or object
  64. register_shutdown_function(): Argument #1 ($callback) must be a valid callback, first array member is not a valid class name or object
  65. register_shutdown_function(): Argument #1 ($callback) must be a valid callback, class bar does not have a method "foo"
  66. register_shutdown_function(): Argument #1 ($callback) must be a valid callback, first array member is not a valid class name or object
  67. register_shutdown_function(): Argument #1 ($callback) must be a valid callback, function "bar" not found or invalid function name
  68. register_shutdown_function(): Argument #1 ($callback) must be a valid callback, non-static method bar::barfoo() cannot be called statically
  69. register_shutdown_function(): Argument #1 ($callback) must be a valid callback, class bar does not have a method "foobar"
  70. foo!
  71. bar!