aboutsummaryrefslogtreecommitdiff
path: root/src/base/QXmppElement.cpp
diff options
context:
space:
mode:
authorBoris Pek <tehnick-8@yandex.ru>2017-02-03 00:10:23 +0300
committerJeremy Lainé <jeremy.laine@m4x.org>2018-09-18 16:28:02 +0200
commitc475518122c4894c1262337750ea22a04f7f9436 (patch)
tree56e7183634d1aae7a186be280b03b47ac124f7d2 /src/base/QXmppElement.cpp
parentcee1f448caff955c621da1ccf1d5cab5025eb26d (diff)
QXmppElement: add self-assignment check to 'operator='.
Diffstat (limited to 'src/base/QXmppElement.cpp')
-rw-r--r--src/base/QXmppElement.cpp11
1 files changed, 7 insertions, 4 deletions
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;
}