From ccaf6502144ec787c0d8cd9fc16bbe903f25b37a Mon Sep 17 00:00:00 2001 From: garima-g Date: Thu, 5 Nov 2015 11:12:24 +0530 Subject: [PATCH] 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; }