mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-8.3'
* PHP-8.3: Add missing NULL checks for spl autoload table Add missing NULL pointer checks related to the previous call frame
This commit is contained in:
commit
f283f50f1a
8 changed files with 78 additions and 6 deletions
|
@ -168,7 +168,7 @@ ZEND_FUNCTION(func_num_args)
|
|||
|
||||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
|
||||
if (ZEND_CALL_INFO(ex) & ZEND_CALL_CODE) {
|
||||
if (ex && (ZEND_CALL_INFO(ex) & ZEND_CALL_CODE)) {
|
||||
zend_throw_error(NULL, "func_num_args() must be called from a function context");
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ ZEND_FUNCTION(func_get_arg)
|
|||
}
|
||||
|
||||
ex = EX(prev_execute_data);
|
||||
if (ZEND_CALL_INFO(ex) & ZEND_CALL_CODE) {
|
||||
if (ex && (ZEND_CALL_INFO(ex) & ZEND_CALL_CODE)) {
|
||||
zend_throw_error(NULL, "func_get_arg() cannot be called from the global scope");
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ ZEND_FUNCTION(func_get_args)
|
|||
|
||||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
|
||||
if (ZEND_CALL_INFO(ex) & ZEND_CALL_CODE) {
|
||||
if (ex && (ZEND_CALL_INFO(ex) & ZEND_CALL_CODE)) {
|
||||
zend_throw_error(NULL, "func_get_args() cannot be called from the global scope");
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
|
|
@ -588,8 +588,10 @@ PHP_FUNCTION(spl_autoload_unregister)
|
|||
|
||||
if (fcc.function_handler && zend_string_equals_literal(
|
||||
fcc.function_handler->common.function_name, "spl_autoload_call")) {
|
||||
/* Don't destroy the hash table, as we might be iterating over it right now. */
|
||||
zend_hash_clean(spl_autoload_functions);
|
||||
if (spl_autoload_functions) {
|
||||
/* Don't destroy the hash table, as we might be iterating over it right now. */
|
||||
zend_hash_clean(spl_autoload_functions);
|
||||
}
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
--TEST--
|
||||
spl_autoload_unregister("spl_autoload_call") without registrations
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(spl_autoload_unregister("spl_autoload_call"));
|
||||
?>
|
||||
Done
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
Done
|
|
@ -1525,7 +1525,7 @@ PHP_FUNCTION(forward_static_call)
|
|||
Z_PARAM_VARIADIC('*', fci.params, fci.param_count)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
if (!EX(prev_execute_data)->func->common.scope) {
|
||||
if (!EX(prev_execute_data) || !EX(prev_execute_data)->func->common.scope) {
|
||||
zend_throw_error(NULL, "Cannot call forward_static_call() when no class scope is active");
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
--TEST--
|
||||
register_shutdown_function() without a previous call frame 01
|
||||
--FILE--
|
||||
<?php
|
||||
register_shutdown_function("forward_static_call", "hash_hkdf");
|
||||
?>
|
||||
Done
|
||||
--EXPECT--
|
||||
Done
|
||||
|
||||
Fatal error: Uncaught Error: Cannot call forward_static_call() when no class scope is active in [no active file]:0
|
||||
Stack trace:
|
||||
#0 [internal function]: forward_static_call('hash_hkdf')
|
||||
#1 {main}
|
||||
thrown in [no active file] on line 0
|
|
@ -0,0 +1,15 @@
|
|||
--TEST--
|
||||
register_shutdown_function() without a previous call frame 02
|
||||
--FILE--
|
||||
<?php
|
||||
register_shutdown_function("func_get_args");
|
||||
?>
|
||||
Done
|
||||
--EXPECT--
|
||||
Done
|
||||
|
||||
Fatal error: Uncaught Error: Cannot call func_get_args() dynamically in [no active file]:0
|
||||
Stack trace:
|
||||
#0 [internal function]: func_get_args()
|
||||
#1 {main}
|
||||
thrown in [no active file] on line 0
|
|
@ -0,0 +1,15 @@
|
|||
--TEST--
|
||||
register_shutdown_function() without a previous call frame 03
|
||||
--FILE--
|
||||
<?php
|
||||
register_shutdown_function("func_num_args");
|
||||
?>
|
||||
Done
|
||||
--EXPECT--
|
||||
Done
|
||||
|
||||
Fatal error: Uncaught Error: Cannot call func_num_args() dynamically in [no active file]:0
|
||||
Stack trace:
|
||||
#0 [internal function]: func_num_args()
|
||||
#1 {main}
|
||||
thrown in [no active file] on line 0
|
|
@ -0,0 +1,15 @@
|
|||
--TEST--
|
||||
register_shutdown_function() without a previous call frame 04
|
||||
--FILE--
|
||||
<?php
|
||||
register_shutdown_function("func_get_arg");
|
||||
?>
|
||||
Done
|
||||
--EXPECT--
|
||||
Done
|
||||
|
||||
Fatal error: Uncaught ArgumentCountError: func_get_arg() expects exactly 1 argument, 0 given in [no active file]:0
|
||||
Stack trace:
|
||||
#0 [internal function]: func_get_arg()
|
||||
#1 {main}
|
||||
thrown in [no active file] on line 0
|
Loading…
Add table
Add a link
Reference in a new issue