From: Nikita Popov Date: Thu, 24 Oct 2019 13:40:25 +0000 (+0200) Subject: Don't check ZEND_TYPE_IS_SET() in zend_check_type() X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9666d7a753e1276b3ead88946af26695aac0d4df;p=php 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. --- diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index cf8d2973bf..5ace501cce 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++;