From 0f9b3de234ab78145f121e7933ded4d545c53be3 Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Tue, 12 Oct 2004 09:13:20 +0000 Subject: [PATCH] - Fix set_exception_handler # unsettign with '' never worked so we use NULL now which is much better # because it matches the the return NULL in case no handler was defined # and can't lead to problems with wrong string operations. --- Zend/zend_builtin_functions.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index c3e0f7eb1f..93e9a9bc93 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -1109,13 +1109,15 @@ ZEND_FUNCTION(set_exception_handler) ZEND_WRONG_PARAM_COUNT(); } - if (!zend_is_callable(*exception_handler, 0, &exception_handler_name)) { - zend_error(E_WARNING, "%s() expects the argument (%s) to be a valid callback", - get_active_function_name(TSRMLS_C), exception_handler_name?exception_handler_name:"unknown"); + if (Z_TYPE_PP(exception_handler) != IS_NULL) { /* NULL == unset */ + if (!zend_is_callable(*exception_handler, 0, &exception_handler_name)) { + zend_error(E_WARNING, "%s() expects the argument (%s) to be a valid callback", + get_active_function_name(TSRMLS_C), exception_handler_name?exception_handler_name:"unknown"); + efree(exception_handler_name); + return; + } efree(exception_handler_name); - return; } - efree(exception_handler_name); if (EG(user_exception_handler)) { had_orig_exception_handler = 1; @@ -1125,7 +1127,7 @@ ZEND_FUNCTION(set_exception_handler) } ALLOC_ZVAL(EG(user_exception_handler)); - if (Z_STRLEN_PP(exception_handler)==0) { /* unset user-defined handler */ + if (Z_TYPE_PP(exception_handler) == IS_NULL) { /* unset user-defined handler */ FREE_ZVAL(EG(user_exception_handler)); EG(user_exception_handler) = NULL; RETURN_TRUE; -- 2.40.0