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