From 9fad0b28a52685b761212ee2a7ee24c2538e3d4e Mon Sep 17 00:00:00 2001 From: garima-g Date: Thu, 5 Nov 2015 11:09:20 +0530 Subject: [PATCH] Add self-assignment check in operator= Method 'operator=' should check its argument with 'this' pointer. --- taglib/ape/apeitem.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/taglib/ape/apeitem.cpp b/taglib/ape/apeitem.cpp index 3490173a..49c3a665 100644 --- a/taglib/ape/apeitem.cpp +++ b/taglib/ape/apeitem.cpp @@ -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; }