Skip to content

Commit 9a83343

Browse files
committed
Delay EG(exception) check on slow path
1 parent d90cdbd commit 9a83343

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

Zend/zend_API.c

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,16 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_count_exception(int
248248
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_type_error(int num, zend_expected_type expected_type, zval *arg) /* {{{ */
249249
{
250250
const char *space;
251-
const char *class_name = get_active_class_name(&space);
251+
const char *class_name;
252252
static const char * const expected_error[] = {
253253
Z_EXPECTED_TYPES(Z_EXPECTED_TYPE_STR)
254254
NULL
255255
};
256256

257+
if (EG(exception)) {
258+
return;
259+
}
260+
class_name = get_active_class_name(&space);
257261
zend_internal_type_error(ZEND_ARG_USES_STRICT_TYPES(), "%s%s%s() expects parameter %d to be %s, %s given",
258262
class_name, space, get_active_function_name(), num, expected_error[expected_type], zend_zval_type_name(arg));
259263
}
@@ -262,12 +266,16 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_type_error(int num, z
262266
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_type_exception(int num, zend_expected_type expected_type, zval *arg) /* {{{ */
263267
{
264268
const char *space;
265-
const char *class_name = get_active_class_name(&space);
269+
const char *class_name;
266270
static const char * const expected_error[] = {
267271
Z_EXPECTED_TYPES(Z_EXPECTED_TYPE_STR)
268272
NULL
269273
};
270274

275+
if (EG(exception)) {
276+
return;
277+
}
278+
class_name = get_active_class_name(&space);
271279
zend_internal_type_error(1, "%s%s%s() expects parameter %d to be %s, %s given",
272280
class_name, space, get_active_function_name(), num, expected_error[expected_type], zend_zval_type_name(arg));
273281
}
@@ -276,8 +284,12 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_type_exception(int nu
276284
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_error(int num, char *name, zval *arg) /* {{{ */
277285
{
278286
const char *space;
279-
const char *class_name = get_active_class_name(&space);
287+
const char *class_name;
280288

289+
if (EG(exception)) {
290+
return;
291+
}
292+
class_name = get_active_class_name(&space);
281293
zend_internal_type_error(ZEND_ARG_USES_STRICT_TYPES(), "%s%s%s() expects parameter %d to be %s, %s given",
282294
class_name, space, get_active_function_name(), num, name, zend_zval_type_name(arg));
283295
}
@@ -286,8 +298,12 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_error(int num,
286298
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_exception(int num, char *name, zval *arg) /* {{{ */
287299
{
288300
const char *space;
289-
const char *class_name = get_active_class_name(&space);
301+
const char *class_name;
290302

303+
if (EG(exception)) {
304+
return;
305+
}
306+
class_name = get_active_class_name(&space);
291307
zend_internal_type_error(1, "%s%s%s() expects parameter %d to be %s, %s given",
292308
class_name, space, get_active_function_name(), num, name, zend_zval_type_name(arg));
293309
}
@@ -296,8 +312,12 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_exception(int n
296312
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int num, char *error) /* {{{ */
297313
{
298314
const char *space;
299-
const char *class_name = get_active_class_name(&space);
315+
const char *class_name;
300316

317+
if (EG(exception)) {
318+
return;
319+
}
320+
class_name = get_active_class_name(&space);
301321
zend_internal_type_error(ZEND_ARG_USES_STRICT_TYPES(), "%s%s%s() expects parameter %d to be a valid callback, %s",
302322
class_name, space, get_active_function_name(), num, error);
303323
efree(error);
@@ -307,8 +327,12 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int num, char *e
307327
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_exception(int num, char *error) /* {{{ */
308328
{
309329
const char *space;
310-
const char *class_name = get_active_class_name(&space);
330+
const char *class_name;
311331

332+
if (EG(exception)) {
333+
return;
334+
}
335+
class_name = get_active_class_name(&space);
312336
zend_internal_type_error(1, "%s%s%s() expects parameter %d to be a valid callback, %s",
313337
class_name, space, get_active_function_name(), num, error);
314338
efree(error);

Zend/zend_API.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_exception(int num, cha
11841184
#define ZEND_PARSE_PARAMETERS_END_EX(failure) \
11851185
} while (0); \
11861186
if (UNEXPECTED(_error_code != ZPP_ERROR_OK)) { \
1187-
if (!(_flags & ZEND_PARSE_PARAMS_QUIET) && !EG(exception)) { \
1187+
if (!(_flags & ZEND_PARSE_PARAMS_QUIET)) { \
11881188
if (_error_code == ZPP_ERROR_WRONG_CALLBACK) { \
11891189
if (_flags & ZEND_PARSE_PARAMS_THROW) { \
11901190
zend_wrong_callback_exception(_i, _error); \

0 commit comments

Comments
 (0)