com php-src: Merge branch 'PHP-5.6': Zend/zend_exceptions.c
| From: | Xinchen Hui | Date: | Tue, 14 Apr 2015 11:33:46 +0000 |
| Subject: | com php-src: Merge branch 'PHP-5.6': Zend/zend_exceptions.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-86218@lists.php.net to get a copy of this message | ||
Commit: e68b851217a4bb68e5c492973d58711081f2a40c
Author: Xinchen Hui <laruence@php.net> Tue, 14 Apr 2015 19:33:46 +0800
Parents: 26a6d707a18701a51269969ea97b8b9b4d851d8a 5fc635548e30fe16b0f112e26db3a4a2dc69522c
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e68b851217a4bb68e5c492973d58711081f2a40c
Log:
Merge branch 'PHP-5.6'
Conflicts:
Zend/zend_exceptions.c
Changed paths:
MM Zend/zend_exceptions.c
Diff:
diff --cc Zend/zend_exceptions.c
index cda0dd9,3e50422..79b2183
--- a/Zend/zend_exceptions.c
+++ b/Zend/zend_exceptions.c
@@@ -549,32 -581,28 +549,32 @@@ static void _build_trace_string(smart_s
Obtain the backtrace for the exception as a string (instead of an array) */
ZEND_METHOD(exception, getTraceAsString)
{
- zval *trace;
- char *res, **str, *s_tmp;
- int res_len = 0, *len = &res_len, num = 0;
+ zval *trace, *frame, rv;
+ zend_ulong index;
+ smart_str str = {0};
+ uint32_t num = 0;
DEFAULT_0_PARAMS;
-
- res = estrdup("");
- str = &res;
- trace = zend_read_property(default_exception_ce, getThis(), "trace",
sizeof("trace")-1, 1 TSRMLS_CC);
+ trace = zend_read_property(base_exception_ce, getThis(), "trace",
sizeof("trace")-1, 1, &rv);
- if(Z_TYPE_P(trace) != IS_ARRAY) {
+ if (Z_TYPE_P(trace) != IS_ARRAY) {
RETURN_FALSE;
}
- zend_hash_apply_with_arguments(Z_ARRVAL_P(trace) TSRMLS_CC,
(apply_func_args_t)_build_trace_string, 3, str, len, &num);
+ ZEND_HASH_FOREACH_NUM_KEY_VAL(Z_ARRVAL_P(trace), index, frame) {
+ if (Z_TYPE_P(frame) != IS_ARRAY) {
+ zend_error(E_WARNING, "Expected array for frame %pu", index);
+ continue;
+ }
+
+ _build_trace_string(&str, Z_ARRVAL_P(frame), num++);
+ } ZEND_HASH_FOREACH_END();
- s_tmp = emalloc(1 + MAX_LENGTH_OF_LONG + 7 + 1);
- sprintf(s_tmp, "#%d {main}", num);
- TRACE_APPEND_STRL(s_tmp, strlen(s_tmp));
- efree(s_tmp);
+ smart_str_appendc(&str, '#');
+ smart_str_append_long(&str, num);
+ smart_str_appends(&str, " {main}");
+ smart_str_0(&str);
- res[res_len] = '\0';
- RETURN_STRINGL(res, res_len, 0);
+ RETURN_NEW_STR(str.s);
}
/* }}} */