mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Add missing NULL pointer checks related to the previous call frame
This commit is contained in:
@@ -154,7 +154,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();
|
||||
}
|
||||
@@ -185,7 +185,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();
|
||||
}
|
||||
@@ -223,7 +223,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();
|
||||
}
|
||||
|
||||
@@ -1541,7 +1541,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
|
||||
Reference in New Issue
Block a user