From: garima-g Date: Thu, 5 Nov 2015 05:42:24 +0000 (+0530) Subject: Add self-assignment check in operator= X-Git-Tag: v1.10~2^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ccaf6502144ec787c0d8cd9fc16bbe903f25b37a;p=taglib Add self-assignment check in operator= Method 'operator=' should check its argument with 'this' pointer. --- 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; }