Bugfix for the Exception class.

This commit is contained in:
Gunnar Beutner 2012-05-21 12:57:44 +02:00
parent eae3d67f02
commit a420d1f801
2 changed files with 13 additions and 12 deletions

View File

@ -26,6 +26,7 @@ using namespace icinga;
*/
Exception::Exception(void)
{
m_Message = NULL;
}
/**
@ -35,9 +36,18 @@ Exception::Exception(void)
*/
Exception::Exception(const char *message)
{
m_Message = NULL;
SetMessage(message);
}
/**
* Destructor for the Exception class. Must be virtual for RTTI to work.
*/
Exception::~Exception(void) throw()
{
Memory::Free(m_Message);
}
/**
* Retrieves the description for the exception.
*
@ -65,9 +75,7 @@ const char *Exception::what(void) const throw()
*/
void Exception::SetMessage(const char *message)
{
if (m_Message)
delete m_Message;
Memory::Free(m_Message);
m_Message = Memory::StrDup(message);
}

View File

@ -31,7 +31,7 @@ namespace icinga
class I2_BASE_API Exception : exception
{
private:
const char *m_Message;
char *m_Message;
protected:
void SetMessage(const char *message);
@ -39,14 +39,7 @@ protected:
public:
Exception(void);
Exception(const char *message);
/**
* Destructor for the Exception class. Must be virtual for RTTI to work.
*/
virtual ~Exception(void) throw()
{
delete m_Message;
}
virtual ~Exception(void) throw();
const char *GetMessage(void) const;