From: Thies C. Arntzen Date: Mon, 2 Sep 2002 12:20:09 +0000 (+0000) Subject: debug_backtrace() now checks the complete argument-stack for consistency. X-Git-Tag: RELEASE_0_91~161 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9afea7175c78fea9a6bd26f03ad0ddd0463c77ee;p=php debug_backtrace() now checks the complete argument-stack for consistency. --- diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 95ba4efbf1..b507d8dea7 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -1280,21 +1280,35 @@ ZEND_FUNCTION(debug_backtrace) char *include_filename = NULL; zval *stack_frame; void **cur_arg_pos = EG(argument_stack).top_element; + void **args = cur_arg_pos; + int arg_stack_consitent = 0; if (ZEND_NUM_ARGS()) { WRONG_PARAM_COUNT; } + while (--args >= EG(argument_stack).elements) { + if (*args--) { + break; + } + args -= *(ulong*)args; + + if (args == EG(argument_stack).elements) { + arg_stack_consitent = 1; + break; + } + } + + if (! arg_stack_consitent) { + zend_error(E_ERROR, "debug_backtrace(): Can't be called by function parameter"); + } + ptr = EG(current_execute_data); /* skip debug_backtrace() */ ptr = ptr->prev_execute_data; cur_arg_pos -= 2; - if (ptr && cur_arg_pos[-1]) { - zend_error(E_ERROR, "debug_backtrace(): Can't be used as a function parameter"); - } - array_init(return_value); while (ptr) {