com php-src: Fixed bug #70323 (Regression in zend_fetch_deb ug_backtrace() can cause segfaults): Zend/zen d_builtin_functions.c
| From: | Anatol Belski | Date: | Sun, 08 Nov 2015 05:05:41 +0000 |
| Subject: | com php-src: Fixed bug #70323 (Regression in zend_fetch_deb ug_backtrace() can cause segfaults): Zend/zen d_builtin_functions.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-89670@lists.php.net to get a copy of this message | ||
Commit: 1cada8e050d606b1a0ea5217f89fe511b5d12c52
Author: Xinchen Hui <laruence@gmail.com> Mon, 9 Nov 2015 17:14:15 +0800
Committer: Anatol Belski <ab@php.net> Sun, 8 Nov 2015 06:05:41 +0100
Parents: 94c9f54f16c2a4245c86b8cf69212b750e1b4326
Branches: PHP-7.0.0
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1cada8e050d606b1a0ea5217f89fe511b5d12c52
Log:
Fixed bug #70323 (Regression in zend_fetch_debug_backtrace() can cause segfaults)
Bugs:
https://bugs.php.net/70323
Changed paths:
M Zend/zend_builtin_functions.c
Diff:
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 8ffdcaa..6faa57c 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++;