com php-src: Don't check ZEND_TYPE_IS_SET() in ze nd_check_type(): Zend/zend_execute.c
| From: | Nikita Popov | Date: | Thu, 24 Oct 2019 13:41:26 +0000 |
| Subject: | com php-src: Don't check ZEND_TYPE_IS_SET() in ze nd_check_type(): Zend/zend_execute.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-109047@lists.php.net to get a copy of this message | ||
Commit: 9666d7a753e1276b3ead88946af26695aac0d4df
Author: Nikita Popov <nikita.ppv@gmail.com> Thu, 24 Oct 2019 15:40:25 +0200
Parents: 1f497b3db7c583a3dafd93ccc687770732c74886
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9666d7a753e1276b3ead88946af26695aac0d4df
Log:
Don't check ZEND_TYPE_IS_SET() in zend_check_type()
Usually this function is only used if we already know that there is
a type. Add checks to the places where we don't.
Changed paths:
M Zend/zend_execute.c
Diff:
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index cf8d2973bfe..5ace501cce1 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -970,10 +970,7 @@ static zend_always_inline zend_bool zend_check_type(
{
zend_reference *ref = NULL;
uint32_t type_mask;
-
- if (!ZEND_TYPE_IS_SET(type)) {
- return 1;
- }
+ ZEND_ASSERT(ZEND_TYPE_IS_SET(type));
if (UNEXPECTED(Z_ISREF_P(arg))) {
ref = Z_REF_P(arg);
@@ -1023,12 +1020,13 @@ static zend_always_inline zend_bool zend_check_type(
static zend_always_inline int zend_verify_recv_arg_type(zend_function *zf, uint32_t arg_num, zval
*arg, void **cache_slot)
{
- zend_arg_info *cur_arg_info = &zf->common.arg_info[arg_num-1];
+ zend_arg_info *cur_arg_info;
ZEND_ASSERT(arg_num <= zf->common.num_args);
cur_arg_info = &zf->common.arg_info[arg_num-1];
- if (UNEXPECTED(!zend_check_type(cur_arg_info->type, arg, cache_slot, zf->common.scope, 0,
0))) {
+ if (ZEND_TYPE_IS_SET(cur_arg_info->type)
+ && UNEXPECTED(!zend_check_type(cur_arg_info->type, arg, cache_slot,
zf->common.scope, 0, 0))) {
zend_verify_arg_error(zf, cur_arg_info, arg_num, cache_slot, arg);
return 0;
}
@@ -1070,7 +1068,8 @@ static zend_never_inline ZEND_ATTRIBUTE_UNUSED int
zend_verify_internal_arg_type
break;
}
- if (UNEXPECTED(!zend_check_type(cur_arg_info->type, arg, &dummy_cache_slot,
fbc->common.scope, 0, /* is_internal */ 1))) {
+ if (ZEND_TYPE_IS_SET(cur_arg_info->type)
+ && UNEXPECTED(!zend_check_type(cur_arg_info->type, arg, &dummy_cache_slot,
fbc->common.scope, 0, /* is_internal */ 1))) {
return 0;
}
arg++;