Make the copy assignment operator of Exception class exception safe

This commit is contained in:
Kontinuation 2014-05-18 20:46:28 +08:00
parent f586911b8f
commit efc1585ae3

View File

@ -65,9 +65,10 @@ Exception& Exception::operator = (const Exception& exc)
{
if (&exc != this)
{
Exception *new_pNested = exc._pNested? exc._pNested->clone() : 0;
delete _pNested;
_msg = exc._msg;
_pNested = exc._pNested ? exc._pNested->clone() : 0;
_pNested = new_pNested;
_code = exc._code;
}
return *this;