summaryrefslogtreecommitdiff
path: root/Zend/zend_API.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2017-12-27 13:26:06 +0300
committerDmitry Stogov <dmitry@zend.com>2017-12-27 13:26:06 +0300
commita6fcbb7c8709d20a471d81839e320693f7636a34 (patch)
tree0d0918b6ba1ae2b12b92db8fcca19453af7ecf90 /Zend/zend_API.c
parent856ad54f4504e1659797f84f8b951e6f80918da3 (diff)
downloadphp-git-a6fcbb7c8709d20a471d81839e320693f7636a34.tar.gz
Use zend_hash_find() instead of zend_hash_find_ptr() to avoid double check
Diffstat (limited to 'Zend/zend_API.c')
-rw-r--r--Zend/zend_API.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 7e19683094..4fea589dfc 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -2907,6 +2907,7 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca
HashTable *ftable;
int call_via_handler = 0;
zend_class_entry *scope;
+ zval *zv;
ALLOCA_FLAG(use_heap)
if (error) {
@@ -2927,11 +2928,13 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca
}
/* Check if function with given name exists.
* This may be a compound name that includes namespace name */
- if (EXPECTED((fcc->function_handler = zend_hash_find_ptr(EG(function_table), lmname)) != NULL)) {
+ zv = zend_hash_find(EG(function_table), lmname);
+ if (EXPECTED(zv != NULL)) {
+ fcc->function_handler = Z_PTR_P(zv);
+ fcc->initialized = 1;
if (lmname != Z_STR_P(callable)) {
ZSTR_ALLOCA_FREE(lmname, use_heap);
}
- fcc->initialized = 1;
return 1;
} else {
if (lmname == Z_STR_P(callable)) {
@@ -2940,9 +2943,11 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca
zend_string_forget_hash_val(lmname);
}
zend_str_tolower(ZSTR_VAL(lmname), ZSTR_LEN(lmname));
- if ((fcc->function_handler = zend_hash_find_ptr(EG(function_table), lmname)) != NULL) {
- ZSTR_ALLOCA_FREE(lmname, use_heap);
+ zv = zend_hash_find(EG(function_table), lmname);
+ if (zv != NULL) {
+ fcc->function_handler = Z_PTR_P(zv);
fcc->initialized = 1;
+ ZSTR_ALLOCA_FREE(lmname, use_heap);
return 1;
}
}
@@ -3010,19 +3015,23 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca
if (fcc->function_handler) {
retval = 1;
}
- } else if ((fcc->function_handler = zend_hash_find_ptr(ftable, lmname)) != NULL) {
+ } else if ((zv = zend_hash_find(ftable, lmname)) != NULL) {
+ fcc->function_handler = Z_PTR_P(zv);
retval = 1;
if ((fcc->function_handler->op_array.fn_flags & ZEND_ACC_CHANGED) &&
!strict_class) {
scope = zend_get_executed_scope();
if (scope &&
instanceof_function(fcc->function_handler->common.scope, scope)) {
- zend_function *priv_fbc;
- if ((priv_fbc = zend_hash_find_ptr(&scope->function_table, lmname)) != NULL
- && priv_fbc->common.fn_flags & ZEND_ACC_PRIVATE
- && priv_fbc->common.scope == scope) {
- fcc->function_handler = priv_fbc;
+ zv = zend_hash_find(&scope->function_table, lmname);
+ if (zv != NULL) {
+ zend_function *priv_fbc = Z_PTR_P(zv);
+
+ if (priv_fbc->common.fn_flags & ZEND_ACC_PRIVATE
+ && priv_fbc->common.scope == scope) {
+ fcc->function_handler = priv_fbc;
+ }
}
}
}