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

taglib/ape/apeitem.cpp

index 3490173a2cda5fb622b6302a06ca530ba8f886ec..49c3a6653a40c238054f967274affc8c7106c386 100644 (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;
 }