From 604761cdc0c2228c48ef394158ee24c3f61bfd3f Mon Sep 17 00:00:00 2001 From: jvoisin Date: Mon, 5 Mar 2018 17:26:41 +0100 Subject: Improve performances by a significant factor Only check if a function should be disabled when we're after a `*CALL` opcode, end not on every single opcode. Based on @blotus ideas ♥--- src/sp_execute.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/sp_execute.c b/src/sp_execute.c index 1517134..bb9f64e 100644 --- a/src/sp_execute.c +++ b/src/sp_execute.c @@ -119,8 +119,24 @@ char *get_eval_filename(const char *const filename) { static void sp_execute_ex(zend_execute_data *execute_data) { is_in_eval_and_whitelisted(execute_data); - if (UNEXPECTED(true == should_disable(execute_data, NULL, NULL, NULL))) { - sp_terminate(); + if (!execute_data) { + return; + } else if (!execute_data->prev_execute_data || + !execute_data->prev_execute_data->func || + !ZEND_USER_CODE(execute_data->prev_execute_data->func->type) || + !execute_data->prev_execute_data->opline) { + if (UNEXPECTED(true == should_disable(execute_data, NULL, NULL, NULL))) { + sp_terminate(); + } + } else if (execute_data->prev_execute_data != NULL) { + if ((execute_data->prev_execute_data->opline->opcode == ZEND_DO_FCALL || + execute_data->prev_execute_data->opline->opcode == ZEND_DO_UCALL || + execute_data->prev_execute_data->opline->opcode == + ZEND_DO_FCALL_BY_NAME)) { + if (UNEXPECTED(true == should_disable(execute_data, NULL, NULL, NULL))) { + sp_terminate(); + } + } } if (UNEXPECTED(EX(func)->op_array.type == ZEND_EVAL_CODE)) { -- cgit v1.3