diff options
| author | Xinchen Hui <laruence@gmail.com> | 2015-11-09 17:14:15 +0800 |
|---|---|---|
| committer | Xinchen Hui <laruence@gmail.com> | 2015-11-09 17:14:15 +0800 |
| commit | d70aa14f2c1617800cbab431db5c2ea021969cc6 (patch) | |
| tree | ef5115fe5abfee8d058f687ccc7b1f7b44c11c91 /Zend/zend_builtin_functions.c | |
| parent | 0a1e199682c1f2503cc78f900c55ad15fcf89b1d (diff) | |
| download | php-git-d70aa14f2c1617800cbab431db5c2ea021969cc6.tar.gz | |
Fixed bug #70323 (Regression in zend_fetch_debug_backtrace() can cause segfaults)
Diffstat (limited to 'Zend/zend_builtin_functions.c')
| -rw-r--r-- | Zend/zend_builtin_functions.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 8ffdcaa0bc..6faa57cd99 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -2481,7 +2481,7 @@ ZEND_FUNCTION(debug_print_backtrace) ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int options, int limit) /* {{{ */ { - zend_execute_data *call, *ptr, *skip; + zend_execute_data *ptr, *skip, *call = NULL; zend_object *object; int lineno, frameno = 0; zend_function *func; @@ -2490,8 +2490,12 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int zend_string *include_filename = NULL; zval stack_frame; - call = NULL; - ptr = EG(current_execute_data); + array_init(return_value); + + if (!(ptr = EG(current_execute_data))) { + return; + } + if (!ptr->func || !ZEND_USER_CODE(ptr->func->common.type)) { call = ptr; ptr = ptr->prev_execute_data; @@ -2509,13 +2513,11 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int ptr = ptr->prev_execute_data; } } + if (!call) { + call = ptr; + ptr = ptr->prev_execute_data; + } } - if (!call) { - call = ptr; - ptr = ptr->prev_execute_data; - } - - array_init(return_value); while (ptr && (limit == 0 || frameno < limit)) { frameno++; |
