From 8b4a27beb409c5a81f956b48c248c4fad0b258a3 Mon Sep 17 00:00:00 2001
From: garima-g <garima.g@samsung.com>
Date: Thu, 5 Nov 2015 11:19:44 +0530
Subject: [PATCH] Add self-assignment check in operator=

Method 'operator=' should check its argument with 'this' pointer.
---
 taglib/mp4/mp4item.cpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/taglib/mp4/mp4item.cpp b/taglib/mp4/mp4item.cpp
index 671f26b4..aa59feda 100644
--- a/taglib/mp4/mp4item.cpp
+++ b/taglib/mp4/mp4item.cpp
@@ -64,11 +64,13 @@ MP4::Item::Item(const Item &item) : d(item.d)
 MP4::Item &
 MP4::Item::operator=(const Item &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;
 }
 
-- 
2.40.0