cvs: ZendEngine2(PHP_5_3) / zend_exceptions.c /tests exception_010.phpt

[email protected] ("Felipe Pena") Mon, 11 May 2009 15:03:47 -0000
Newsgroups php.zend-engine.cvs
Message-ID <cvsfelipe1242054227@cvsserver>
felipe		Mon May 11 15:03:47 2009 UTC

  Added files:                 (Branch: PHP_5_3)
    /ZendEngine2/tests	exception_010.phpt 

  Modified files:              
    /ZendEngine2	zend_exceptions.c 
  Log:
  - MFH: Fix code && new test
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_exceptions.c?r1=1.79.2.6.2.9.2.21&r2=1.79.2.6.2.9.2.22&diff_format=u
Index: ZendEngine2/zend_exceptions.c
diff -u ZendEngine2/zend_exceptions.c:1.79.2.6.2.9.2.21 ZendEngine2/zend_exceptions.c:1.79.2.6.2.9.2.22
--- ZendEngine2/zend_exceptions.c:1.79.2.6.2.9.2.21	Mon May 11 14:14:52 2009
+++ ZendEngine2/zend_exceptions.c	Mon May 11 15:03:46 2009
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_exceptions.c,v 1.79.2.6.2.9.2.21 2009/05/11 14:14:52 felipe Exp $ */
+/* $Id: zend_exceptions.c,v 1.79.2.6.2.9.2.22 2009/05/11 15:03:46 felipe Exp $ */
 
 #include "zend.h"
 #include "zend_API.h"
@@ -487,10 +487,13 @@
 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) TSRMLS_CC, (apply_func_args_t)_build_trace_string, 3, str, len, &num);
@@ -534,12 +537,14 @@
 ZEND_METHOD(exception, __toString)
 {
 	zval message, file, line, *trace, *exception;
-	char *str = estrndup("", 0), *prev_str;
+	char *str, *prev_str;
 	int len = 0;
 	zend_fcall_info fci;
 	zval fname;
 	
 	DEFAULT_0_PARAMS;
+	
+	str = estrndup("", 0);
 
 	exception = getThis();
 	ZVAL_STRINGL(&fname, "gettraceasstring", sizeof("gettraceasstring")-1, 1);

http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/exception_010.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/exception_010.phpt
+++ ZendEngine2/tests/exception_010.phpt
--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: Exception::getTraceAsString() expects exactly 0 parameters, 1 given in %s on line %d

Warning: Exception::__toString() expects exactly 0 parameters, 1 given in %s on line %d

Warning: Exception::getTrace() expects exactly 0 parameters, 1 given in %s on line %d

Warning: Exception::getLine() expects exactly 0 parameters, 1 given in %s on line %d

Warning: Exception::getFile() expects exactly 0 parameters, 1 given in %s on line %d

Warning: Exception::getMessage() expects exactly 0 parameters, 1 given in %s on line %d

Warning: Exception::getCode() expects exactly 0 parameters, 1 given in %s on line %d