mirror of
https://github.com/php/php-src.git
synced 2024-09-22 10:27:25 +00:00
cf9b030a57
It's actually not php-cli specific, nor SAPI specific. We should delay the registration of the function into the function table until after the compilation was successful, otherwise the function is mistakingly registered and a NULL dereference will happen when trying to call it. I based my test of Nikita's test, so credits to him for the test: https://github.com/php/php-src/pull/8933#issuecomment-1259881008 Closes GH-10989.
31 lines
709 B
PHP
31 lines
709 B
PHP
--TEST--
|
|
GH-8841 (php-cli core dump calling a badly formed function)
|
|
--FILE--
|
|
<?php
|
|
register_shutdown_function(function() {
|
|
echo "Before calling g()\n";
|
|
g(1);
|
|
echo "After calling g()\n";
|
|
});
|
|
|
|
register_shutdown_function(function() {
|
|
echo "Before calling f()\n";
|
|
f(1);
|
|
echo "After calling f()\n";
|
|
});
|
|
|
|
eval('function g($x): int { return $x; }');
|
|
eval('function f($x): void { return $x; }');
|
|
?>
|
|
--EXPECTF--
|
|
Fatal error: A void function must not return a value in %s on line %d
|
|
Before calling g()
|
|
After calling g()
|
|
Before calling f()
|
|
|
|
Fatal error: Uncaught Error: Call to undefined function f() in %s:%d
|
|
Stack trace:
|
|
#0 [internal function]: {closure}()
|
|
#1 {main}
|
|
thrown in %s on line %d
|