From c475518122c4894c1262337750ea22a04f7f9436 Mon Sep 17 00:00:00 2001 From: Boris Pek Date: Fri, 3 Feb 2017 00:10:23 +0300 Subject: QXmppElement: add self-assignment check to 'operator='. --- src/base/QXmppElement.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/base/QXmppElement.cpp') diff --git a/src/base/QXmppElement.cpp b/src/base/QXmppElement.cpp index 4c6c7f9c..0d6c36e7 100644 --- a/src/base/QXmppElement.cpp +++ b/src/base/QXmppElement.cpp @@ -123,10 +123,13 @@ QXmppElement::~QXmppElement() QXmppElement &QXmppElement::operator=(const QXmppElement &other) { - other.d->counter.ref(); - if (!d->counter.deref()) - delete d; - d = other.d; + if (this != &other) // self-assignment check + { + other.d->counter.ref(); + if (!d->counter.deref()) + delete d; + d = other.d; + } return *this; } -- cgit v1.2.3