diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-10-22 09:32:39 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-10-22 12:54:08 +0200 |
commit | e5e0cc68f70d35e1849aeaf21c0ce68afd6a1f59 (patch) | |
tree | b4bce95d15819feb2c38e183c3ccdcbab76db60c /cppuhelper | |
parent | fd56d5fd409c832886bf42a020322e69b6a35d9e (diff) |
pvs-studio: V794 The assignment operator should be protected
Change-Id: Ia443a0e61a091d877c8da26bf7d45bf4261f8669
Reviewed-on: https://gerrit.libreoffice.org/62166
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'cppuhelper')
-rw-r--r-- | cppuhelper/source/unourl.cxx | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/cppuhelper/source/unourl.cxx b/cppuhelper/source/unourl.cxx index 22250e5568eb..f131a81f68a6 100644 --- a/cppuhelper/source/unourl.cxx +++ b/cppuhelper/source/unourl.cxx @@ -140,9 +140,12 @@ UnoUrlDescriptor::~UnoUrlDescriptor() UnoUrlDescriptor & UnoUrlDescriptor::operator =(UnoUrlDescriptor const & rOther) { - std::unique_ptr<Impl> newImpl(rOther.m_pImpl->clone()); - delete m_pImpl; - m_pImpl = newImpl.release(); + if (this != &rOther) + { + std::unique_ptr<Impl> newImpl(rOther.m_pImpl->clone()); + delete m_pImpl; + m_pImpl = newImpl.release(); + } return *this; } @@ -237,9 +240,12 @@ UnoUrl::~UnoUrl() UnoUrl & UnoUrl::operator =(UnoUrl const & rOther) { - std::unique_ptr<Impl> newImpl(rOther.m_pImpl->clone()); - delete m_pImpl; - m_pImpl = newImpl.release(); + if (this != &rOther) + { + std::unique_ptr<Impl> newImpl(rOther.m_pImpl->clone()); + delete m_pImpl; + m_pImpl = newImpl.release(); + } return *this; } |