From a820665eea71a64b40e74ed24afeaf07a7a99db4 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 26 May 2006 14:36:57 +0000 Subject: Added the first of many unit tests. For now the unit tests are just built with everything else in the all target of the makefile, which is fine, but relies on CppTest, which can be found at http://cpptest.sf.net Also fixed some things I've been meaning to get to for a while in the xml system, including a few bugs that will make coping with malformed data not hang other programs, and do the error reporting in a nice way. --- src/exception.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/exception.cpp') diff --git a/src/exception.cpp b/src/exception.cpp index 291a198..3cde134 100644 --- a/src/exception.cpp +++ b/src/exception.cpp @@ -2,7 +2,8 @@ #include Exception::Exception( const char *lpFormat, ... ) throw() : - nErrorCode( 0 ) + nErrorCode( 0 ), + sWhat( NULL ) { va_list ap; @@ -12,7 +13,8 @@ Exception::Exception( const char *lpFormat, ... ) throw() : } Exception::Exception( int nCode, const char *lpFormat, ... ) throw() : - nErrorCode( nCode ) + nErrorCode( nCode ), + sWhat( NULL ) { va_list ap; @@ -29,11 +31,16 @@ Exception::Exception( int nCode ) throw() : Exception::~Exception() throw() { - delete[] sWhat; + if( sWhat ) + { + delete[] sWhat; + sWhat = NULL; + } } void Exception::setWhat( const char *lpFormat, va_list &vargs ) { + if( sWhat ) delete[] sWhat; int nSize; nSize = vsnprintf( NULL, 0, lpFormat, vargs ); -- cgit v1.2.3