diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-03-11 13:56:22 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-03-11 14:00:33 +0100 |
commit | ac79d42ba6ed05c5dcb611b66cdad07f3bcbba58 (patch) | |
tree | 52e8f8b98f1e67d8be93114bde8784d617e48835 /Zend/zend_API.c | |
parent | 409e0dd29f3163490b6e27661e5c79c93b57e98b (diff) | |
download | php-git-ac79d42ba6ed05c5dcb611b66cdad07f3bcbba58.tar.gz |
Free trampolines from get_closure in is_callable
Also extract this logic into a function, as it's duplicated a few times.
Diffstat (limited to 'Zend/zend_API.c')
-rw-r--r-- | Zend/zend_API.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 8bcd175be4..80a975252d 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -2907,6 +2907,19 @@ static int zend_is_callable_check_class(zend_string *name, zend_class_entry *sco } /* }}} */ +static void free_fcc(zend_fcall_info_cache *fcc) { + if (fcc->function_handler && + ((fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) || + fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY || + fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) { + if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION && + fcc->function_handler->common.function_name) { + zend_string_release_ex(fcc->function_handler->common.function_name, 0); + } + zend_free_trampoline(fcc->function_handler); + } +} + static zend_always_inline int zend_is_callable_check_func(int check_flags, zval *callable, zend_fcall_info_cache *fcc, int strict_class, char **error) /* {{{ */ { zend_class_entry *ce_org = fcc->calling_scope; @@ -3269,16 +3282,8 @@ again: check_func: ret = zend_is_callable_check_func(check_flags, callable, fcc, strict_class, error); - if (fcc == &fcc_local && - fcc->function_handler && - ((fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) || - fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY || - fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) { - if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION && - fcc->function_handler->common.function_name) { - zend_string_release_ex(fcc->function_handler->common.function_name, 0); - } - zend_free_trampoline(fcc->function_handler); + if (fcc == &fcc_local) { + free_fcc(fcc); } return ret; @@ -3346,6 +3351,9 @@ check_func: case IS_OBJECT: if (Z_OBJ_HANDLER_P(callable, get_closure) && Z_OBJ_HANDLER_P(callable, get_closure)(callable, &fcc->calling_scope, &fcc->function_handler, &fcc->object) == SUCCESS) { fcc->called_scope = fcc->calling_scope; + if (fcc == &fcc_local) { + free_fcc(fcc); + } return 1; } if (error) *error = estrdup("no array or string given"); @@ -3386,15 +3394,7 @@ ZEND_API zend_bool zend_make_callable(zval *callable, zend_string **callable_nam add_next_index_str(callable, zend_string_copy(fcc.calling_scope->name)); add_next_index_str(callable, zend_string_copy(fcc.function_handler->common.function_name)); } - if (fcc.function_handler && - ((fcc.function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) || - fcc.function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY || - fcc.function_handler->type == ZEND_OVERLOADED_FUNCTION)) { - if (fcc.function_handler->type != ZEND_OVERLOADED_FUNCTION) { - zend_string_release_ex(fcc.function_handler->common.function_name, 0); - } - zend_free_trampoline(fcc.function_handler); - } + free_fcc(&fcc); return 1; } return 0; |