diff options
| author | Mark Plomer <mark.plomer@boerse-go.de> | 2020-02-24 21:32:02 +0100 |
|---|---|---|
| committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-02-25 12:43:42 +0100 |
| commit | 8c6a7c3326f000af0a8ea266143059e5a463e626 (patch) | |
| tree | 3bc0ed7a59127e2f0bd17c27446e6afd227f0913 /Zend/zend_builtin_functions.c | |
| parent | 56cdbe63c24b86c2f1d60bf2609fde113d12d235 (diff) | |
| download | php-git-8c6a7c3326f000af0a8ea266143059e5a463e626.tar.gz | |
Fix #63206: Fully support error/exception_handler stacking, even with null or inside the handler
Always push the current user_error/exception_handler to the stack,
even when it is empty, so restore_error_handler() always works as
expected.
The user_error_handler is especially temporarily empty when we are inside
the error handler, which caused inconsistent behaviour before.
Diffstat (limited to 'Zend/zend_builtin_functions.c')
| -rw-r--r-- | Zend/zend_builtin_functions.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index f4c4a4f31d..69fbeec1e1 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -1665,11 +1665,11 @@ ZEND_FUNCTION(set_error_handler) if (Z_TYPE(EG(user_error_handler)) != IS_UNDEF) { ZVAL_COPY(return_value, &EG(user_error_handler)); - - zend_stack_push(&EG(user_error_handlers_error_reporting), &EG(user_error_handler_error_reporting)); - zend_stack_push(&EG(user_error_handlers), &EG(user_error_handler)); } + zend_stack_push(&EG(user_error_handlers_error_reporting), &EG(user_error_handler_error_reporting)); + zend_stack_push(&EG(user_error_handlers), &EG(user_error_handler)); + if (Z_TYPE_P(error_handler) == IS_NULL) { /* unset user-defined handler */ ZVAL_UNDEF(&EG(user_error_handler)); return; @@ -1732,10 +1732,10 @@ ZEND_FUNCTION(set_exception_handler) if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) { ZVAL_COPY(return_value, &EG(user_exception_handler)); - - zend_stack_push(&EG(user_exception_handlers), &EG(user_exception_handler)); } + zend_stack_push(&EG(user_exception_handlers), &EG(user_exception_handler)); + if (Z_TYPE_P(exception_handler) == IS_NULL) { /* unset user-defined handler */ ZVAL_UNDEF(&EG(user_exception_handler)); return; |
