From 9fad0b28a52685b761212ee2a7ee24c2538e3d4e Mon Sep 17 00:00:00 2001 From: garima-g Date: Thu, 5 Nov 2015 11:09:20 +0530 Subject: [PATCH 1/4] 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; } From ccaf6502144ec787c0d8cd9fc16bbe903f25b37a Mon Sep 17 00:00:00 2001 From: garima-g Date: Thu, 5 Nov 2015 11:12:24 +0530 Subject: [PATCH 2/4] Add self-assignment check in operator= Method 'operator=' should check its argument with 'this' pointer. --- taglib/asf/asfattribute.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/taglib/asf/asfattribute.cpp b/taglib/asf/asfattribute.cpp index 116bfe21..7a40bea3 100644 --- a/taglib/asf/asfattribute.cpp +++ b/taglib/asf/asfattribute.cpp @@ -72,10 +72,12 @@ ASF::Attribute::Attribute(const ASF::Attribute &other) ASF::Attribute &ASF::Attribute::operator=(const ASF::Attribute &other) { - if(d->deref()) - delete d; - d = other.d; - d->ref(); + if(&other != this) { + if(d->deref()) + delete d; + d = other.d; + d->ref(); + } return *this; } From 998ebf4ce6bc7d512b1c172a5ba286c616abcb11 Mon Sep 17 00:00:00 2001 From: garima-g Date: Thu, 5 Nov 2015 11:16:34 +0530 Subject: [PATCH 3/4] Add self-assignment check in operator= Method 'operator=' should check its argument with 'this' pointer. --- taglib/mp4/mp4coverart.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/taglib/mp4/mp4coverart.cpp b/taglib/mp4/mp4coverart.cpp index 2746469d..f2152335 100644 --- a/taglib/mp4/mp4coverart.cpp +++ b/taglib/mp4/mp4coverart.cpp @@ -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; } From 8b4a27beb409c5a81f956b48c248c4fad0b258a3 Mon Sep 17 00:00:00 2001 From: garima-g Date: Thu, 5 Nov 2015 11:19:44 +0530 Subject: [PATCH 4/4] 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; }