]> granicus.if.org Git - taglib/commitdiff
Add self-assignment check in operator=
authorgarima-g <garima.g@samsung.com>
Thu, 5 Nov 2015 05:46:34 +0000 (11:16 +0530)
committergarima-g <garima.g@samsung.com>
Thu, 5 Nov 2015 05:46:34 +0000 (11:16 +0530)
Method 'operator=' should check its argument with 'this' pointer.

taglib/mp4/mp4coverart.cpp

index 2746469d3fe677872ac9039b0ba189e1b71b28ee..f21523356f5c28a6fc1561890856fbaa781affba 100644 (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;
 }