Add self-assignment check in operator=

Method 'operator=' should check its argument with 'this' pointer.
This commit is contained in:
garima-g
2015-11-05 11:09:20 +05:30
parent 153820bf12
commit 9fad0b28a5

View File

@ -86,8 +86,10 @@ APE::Item::~Item()
Item &APE::Item::operator=(const Item &item)
{
delete d;
d = new ItemPrivate(*item.d);
if(&item != this) {
delete d;
d = new ItemPrivate(*item.d);
}
return *this;
}