summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Pena <felipe@php.net>2009-05-11 15:13:35 +0000
committerFelipe Pena <felipe@php.net>2009-05-11 15:13:35 +0000
commite40df88ad6d55011482daaa222fc8286affa8ecc (patch)
treeeb34051636a4e0f565dd462ad4b39615dbe0a155
parentaa1be9514f2970e57730ea2ee3a971b455b2062f (diff)
downloadphp-git-e40df88ad6d55011482daaa222fc8286affa8ecc.tar.gz
- MFH: Fix code && new test
-rw-r--r--Zend/tests/exception_010.phpt30
-rw-r--r--Zend/zend_exceptions.c5
2 files changed, 34 insertions, 1 deletions
diff --git a/Zend/tests/exception_010.phpt b/Zend/tests/exception_010.phpt
new file mode 100644
index 0000000000..9051731489
--- /dev/null
+++ b/Zend/tests/exception_010.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Testing Exception's methods
+--FILE--
+<?php
+
+$x = new Exception;
+$x->gettraceasstring(1);
+$x->gettraceasstring();
+$x->__tostring(1);
+$x->gettrace(1);
+$x->getline(1);
+$x->getfile(1);
+$x->getmessage(1);
+$x->getcode(1);
+
+?>
+--EXPECTF--
+Warning: Wrong parameter count for Exception::getTraceAsString() in %s on line %d
+
+Warning: Wrong parameter count for Exception::__toString() in %s on line %d
+
+Warning: Wrong parameter count for Exception::getTrace() in %s on line %d
+
+Warning: Wrong parameter count for Exception::getLine() in %s on line %d
+
+Warning: Wrong parameter count for Exception::getFile() in %s on line %d
+
+Warning: Wrong parameter count for Exception::getMessage() in %s on line %d
+
+Warning: Wrong parameter count for Exception::getCode() in %s on line %d
diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c
index f342248291..7083198fdb 100644
--- a/Zend/zend_exceptions.c
+++ b/Zend/zend_exceptions.c
@@ -428,10 +428,13 @@ static int _build_trace_string(zval **frame, int num_args, va_list args, zend_ha
ZEND_METHOD(exception, getTraceAsString)
{
zval *trace;
- char *res = estrdup(""), **str = &res, *s_tmp;
+ char *res, **str, *s_tmp;
int res_len = 0, *len = &res_len, num = 0;
DEFAULT_0_PARAMS;
+
+ res = estrdup("");
+ str = &res;
trace = zend_read_property(default_exception_ce, getThis(), "trace", sizeof("trace")-1, 1 TSRMLS_CC);
zend_hash_apply_with_arguments(Z_ARRVAL_P(trace), (apply_func_args_t)_build_trace_string, 3, str, len, &num);