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