mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
Use ZPP callable check for Windows specific functions
This commit is contained in:
parent
9cb522166c
commit
dae83cd7cb
3 changed files with 11 additions and 16 deletions
|
@ -87,10 +87,13 @@ static BOOL WINAPI php_win32_signal_system_ctrl_handler(DWORD evt)
|
|||
/* {{{ Assigns a CTRL signal handler to a PHP function */
|
||||
PHP_FUNCTION(sapi_windows_set_ctrl_handler)
|
||||
{
|
||||
zval *handler = NULL;
|
||||
zend_fcall_info fci;
|
||||
zend_fcall_info_cache fcc;
|
||||
zend_bool add = 1;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|b", &handler, &add) == FAILURE) {
|
||||
|
||||
/* callable argument corresponds to the CTRL handler */
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "f!|b", &fci, &fcc, &add) == FAILURE) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
|
@ -106,8 +109,7 @@ PHP_FUNCTION(sapi_windows_set_ctrl_handler)
|
|||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
|
||||
if (IS_NULL == Z_TYPE_P(handler)) {
|
||||
if (!ZEND_FCI_INITIALIZED(fci)) {
|
||||
zval_dtor(&ctrl_handler);
|
||||
ZVAL_UNDEF(&ctrl_handler);
|
||||
if (!SetConsoleCtrlHandler(NULL, add)) {
|
||||
|
@ -116,20 +118,15 @@ PHP_FUNCTION(sapi_windows_set_ctrl_handler)
|
|||
RETURN_TRUE;
|
||||
}
|
||||
|
||||
if (!zend_is_callable(handler, 0, NULL)) {
|
||||
zend_argument_type_error(1, "must be a valid callable function name");
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
if (!SetConsoleCtrlHandler(NULL, FALSE) || !SetConsoleCtrlHandler(php_win32_signal_system_ctrl_handler, add)) {
|
||||
zend_string *func_name = zend_get_callable_name(handler);
|
||||
zend_string *func_name = zend_get_callable_name(&fci.function_name);
|
||||
php_error_docref(NULL, E_WARNING, "Unable to attach %s as a CTRL handler", ZSTR_VAL(func_name));
|
||||
zend_string_release_ex(func_name, 0);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
zval_dtor(&ctrl_handler);
|
||||
ZVAL_COPY(&ctrl_handler, handler);
|
||||
ZVAL_COPY(&ctrl_handler, &fci.function_name);
|
||||
|
||||
RETURN_TRUE;
|
||||
}/*}}}*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue