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; } 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; } 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; } 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; }