com php-src: Free trampolines from get_closure in is_ca llable: Zend/zend_API.c

From: Date: Mon, 11 Mar 2019 13:00:33 +0000
Subject: com php-src: Free trampolines from get_closure in is_ca llable: Zend/zend_API.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-105078@lists.php.net to get a copy of this message
Commit: ac79d42ba6ed05c5dcb611b66cdad07f3bcbba58 Author: Nikita Popov <nikita.ppv@gmail.com> Mon, 11 Mar 2019 13:56:22 +0100 Parents: 409e0dd29f3163490b6e27661e5c79c93b57e98b Branches: PHP-7.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ac79d42ba6ed05c5dcb611b66cdad07f3bcbba58 Log: Free trampolines from get_closure in is_callable Also extract this logic into a function, as it's duplicated a few times. Changed paths: M Zend/zend_API.c Diff: diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 8bcd175..80a9752 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;

« previous php.cvs (#105078) next »