]> granicus.if.org Git - php/commitdiff
Delay EG(exception) check on slow path
authorDmitry Stogov <dmitry@zend.com>
Mon, 8 Jul 2019 10:56:34 +0000 (13:56 +0300)
committerDmitry Stogov <dmitry@zend.com>
Mon, 8 Jul 2019 10:56:34 +0000 (13:56 +0300)
Zend/zend_API.c
Zend/zend_API.h

index edc2ba7bc91d94f86bce167b5f1469e96095cf31..2e8fabfcc6b6866518858f2aeea786005c925533 100644 (file)
@@ -248,12 +248,16 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_count_exception(int
 ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_type_error(int num, zend_expected_type expected_type, zval *arg) /* {{{ */
 {
        const char *space;
-       const char *class_name = get_active_class_name(&space);
+       const char *class_name;
        static const char * const expected_error[] = {
                Z_EXPECTED_TYPES(Z_EXPECTED_TYPE_STR)
                NULL
        };
 
+       if (EG(exception)) {
+               return;
+       }
+       class_name = get_active_class_name(&space);
        zend_internal_type_error(ZEND_ARG_USES_STRICT_TYPES(), "%s%s%s() expects parameter %d to be %s, %s given",
                class_name, space, get_active_function_name(), num, expected_error[expected_type], zend_zval_type_name(arg));
 }
@@ -262,12 +266,16 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_type_error(int num, z
 ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_type_exception(int num, zend_expected_type expected_type, zval *arg) /* {{{ */
 {
        const char *space;
-       const char *class_name = get_active_class_name(&space);
+       const char *class_name;
        static const char * const expected_error[] = {
                Z_EXPECTED_TYPES(Z_EXPECTED_TYPE_STR)
                NULL
        };
 
+       if (EG(exception)) {
+               return;
+       }
+       class_name = get_active_class_name(&space);
        zend_internal_type_error(1, "%s%s%s() expects parameter %d to be %s, %s given",
                class_name, space, get_active_function_name(), num, expected_error[expected_type], zend_zval_type_name(arg));
 }
@@ -276,8 +284,12 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_type_exception(int nu
 ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_error(int num, char *name, zval *arg) /* {{{ */
 {
        const char *space;
-       const char *class_name = get_active_class_name(&space);
+       const char *class_name;
 
+       if (EG(exception)) {
+               return;
+       }
+       class_name = get_active_class_name(&space);
        zend_internal_type_error(ZEND_ARG_USES_STRICT_TYPES(), "%s%s%s() expects parameter %d to be %s, %s given",
                class_name, space, get_active_function_name(), num, name, zend_zval_type_name(arg));
 }
@@ -286,8 +298,12 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_error(int num,
 ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_exception(int num, char *name, zval *arg) /* {{{ */
 {
        const char *space;
-       const char *class_name = get_active_class_name(&space);
+       const char *class_name;
 
+       if (EG(exception)) {
+               return;
+       }
+       class_name = get_active_class_name(&space);
        zend_internal_type_error(1, "%s%s%s() expects parameter %d to be %s, %s given",
                class_name, space, get_active_function_name(), num, name, zend_zval_type_name(arg));
 }
@@ -296,8 +312,12 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_exception(int n
 ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int num, char *error) /* {{{ */
 {
        const char *space;
-       const char *class_name = get_active_class_name(&space);
+       const char *class_name;
 
+       if (EG(exception)) {
+               return;
+       }
+       class_name = get_active_class_name(&space);
        zend_internal_type_error(ZEND_ARG_USES_STRICT_TYPES(), "%s%s%s() expects parameter %d to be a valid callback, %s",
                class_name, space, get_active_function_name(), num, error);
        efree(error);
@@ -307,8 +327,12 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int num, char *e
 ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_exception(int num, char *error) /* {{{ */
 {
        const char *space;
-       const char *class_name = get_active_class_name(&space);
+       const char *class_name;
 
+       if (EG(exception)) {
+               return;
+       }
+       class_name = get_active_class_name(&space);
        zend_internal_type_error(1, "%s%s%s() expects parameter %d to be a valid callback, %s",
                class_name, space, get_active_function_name(), num, error);
        efree(error);
index ddf8fbfc749a4c43b4b859dcd9a710dc956a6592..e78ba92595c45fcb0dc0f024e3f5a45981deccc9 100644 (file)
@@ -1184,7 +1184,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_exception(int num, cha
 #define ZEND_PARSE_PARAMETERS_END_EX(failure) \
                } while (0); \
                if (UNEXPECTED(_error_code != ZPP_ERROR_OK)) { \
-                       if (!(_flags & ZEND_PARSE_PARAMS_QUIET) && !EG(exception)) { \
+                       if (!(_flags & ZEND_PARSE_PARAMS_QUIET)) { \
                                if (_error_code == ZPP_ERROR_WRONG_CALLBACK) { \
                                        if (_flags & ZEND_PARSE_PARAMS_THROW) { \
                                                zend_wrong_callback_exception(_i, _error); \