From: Amos Jeffries Date: Sun, 12 Jul 2009 09:06:29 +0000 (+1200) Subject: Author: Martin Huter X-Git-Tag: SQUID_3_2_0_1~889 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=77442705c5969dcb54637c1b3286d8eb923f4caf;p=thirdparty%2Fsquid.git Author: Martin Huter Bug 2658: Missing TextException copy constructor --- diff --git a/src/TextException.cc b/src/TextException.cc index ada4f5c6ba..03592658f7 100644 --- a/src/TextException.cc +++ b/src/TextException.cc @@ -1,13 +1,36 @@ #include "squid.h" #include "TextException.h" +TextException::TextException() +{ + message=NULL; + theFileName=NULL; + theLineNo=0; +} + +TextException::TextException(const TextException& right) : + message((right.message?xstrdup(right.message):NULL)), theFileName(right.theFileName), theLineNo(right.theLineNo) +{ +} + TextException::TextException(const char *aMsg, const char *aFileName, int aLineNo): message(xstrdup(aMsg)), theFileName(aFileName), theLineNo(aLineNo) {} TextException::~TextException() throw() { - xfree(message); + if(message) xfree(message); +} + +TextException& TextException::operator=(const TextException &right) +{ + if(this==&right) return *this; + if(message) xfree(message); + message=(right.message?xstrdup(right.message):NULL); + theFileName=right.theFileName; + theLineNo=right.theLineNo; + + return *this; } const char *TextException::what() const throw() diff --git a/src/TextException.h b/src/TextException.h index 27b44b063c..5edf33f17a 100644 --- a/src/TextException.h +++ b/src/TextException.h @@ -13,11 +13,15 @@ class TextException: public std::exception { public: + TextException(); TextException(const char *aMessage, const char *aFileName = 0, int aLineNo = -1); + TextException(const TextException& right); virtual ~TextException() throw(); virtual const char *what() const throw(); + TextException& operator=(const TextException &right); + public: char *message; // read-only