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:16:34 +05:30
parent ccaf650214
commit 998ebf4ce6

View File

@ -54,11 +54,12 @@ MP4::CoverArt::CoverArt(const CoverArt &item) : d(item.d)
MP4::CoverArt &
MP4::CoverArt::operator=(const CoverArt &item)
{
if(d->deref()) {
delete d;
if(&item != this) {
if(d->deref())
delete d;
d = item.d;
d->ref();
}
d = item.d;
d->ref();
return *this;
}