From: Gunnar Beutner Date: Mon, 21 May 2012 10:57:44 +0000 (+0200) Subject: Bugfix for the Exception class. X-Git-Tag: v0.0.1~498 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a420d1f80133643e813f526f731b671a9949352d;p=icinga2 Bugfix for the Exception class. --- diff --git a/base/exception.cpp b/base/exception.cpp index 8f8af1ed3..bdc0e82ac 100644 --- a/base/exception.cpp +++ b/base/exception.cpp @@ -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); } diff --git a/base/exception.h b/base/exception.h index a85b039ba..114a90226 100644 --- a/base/exception.h +++ b/base/exception.h @@ -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;