From 231f3f125a665e2bc46052d5c9ee1d41951520cb Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Wed, 15 Jul 2009 22:03:09 +1200 Subject: [PATCH] Author: Martin Huter Bug 2658: Missing TextException copy constructor --- src/TextException.cc | 25 ++++++++++++++++++++++++- src/TextException.h | 4 ++++ 2 files changed, 28 insertions(+), 1 deletion(-) 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 -- 2.47.3