-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix GH-8841: php-cli core dump calling a badly formed function
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: #8933 (comment) Closes GH-10989.
- Loading branch information
Showing
3 changed files
with
47 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters