]> granicus.if.org Git - php/commitdiff
- Fix set_exception_handler
authorMarcus Boerger <helly@php.net>
Tue, 12 Oct 2004 09:13:20 +0000 (09:13 +0000)
committerMarcus Boerger <helly@php.net>
Tue, 12 Oct 2004 09:13:20 +0000 (09:13 +0000)
# 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

index c3e0f7eb1f7a50530365667a0c3461d18bf342e0..93e9a9bc93c04018fc3cc496aca2d27689f102f7 100644 (file)
@@ -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;