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:12:24 +05:30
parent 9fad0b28a5
commit ccaf650214

View File

@ -72,10 +72,12 @@ ASF::Attribute::Attribute(const ASF::Attribute &other)
ASF::Attribute &ASF::Attribute::operator=(const ASF::Attribute &other)
{
if(d->deref())
delete d;
d = other.d;
d->ref();
if(&other != this) {
if(d->deref())
delete d;
d = other.d;
d->ref();
}
return *this;
}