diff options
author | Albert Astals Cid <aacid@kde.org> | 2019-11-29 14:42:31 +0100 |
---|---|---|
committer | Albert Astals Cid <aacid@kde.org> | 2019-11-29 14:43:26 +0100 |
commit | ec2b036e0029e94183a87471c83577336bbaedda (patch) | |
tree | 3c2846c382a791fe9e42a54bbe303fd509b6c5b2 | |
parent | 98dbe4becbebb96dc46a581dad338e84d747334e (diff) |
Return early in operator= if we're assigning to ourselves
Makes bugprone-unhandled-self-assignment happy
-rw-r--r-- | cpp/poppler-image.cpp | 5 | ||||
-rw-r--r-- | qt5/src/poppler-outline.cc | 3 |
2 files changed, 7 insertions, 1 deletions
diff --git a/cpp/poppler-image.cpp b/cpp/poppler-image.cpp index 261c5f7b..daf10f02 100644 --- a/cpp/poppler-image.cpp +++ b/cpp/poppler-image.cpp @@ -1,7 +1,7 @@ /* * Copyright (C) 2010-2011, Pino Toscano <pino@kde.org> * Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> - * Copyright (C) 2017, 2018, Albert Astals Cid <aacid@kde.org> + * Copyright (C) 2017-2019, Albert Astals Cid <aacid@kde.org> * Copyright (C) 2017, Jeroen Ooms <jeroenooms@gmail.com> * Copyright (C) 2018, Zsombor Hollay-Horvath <hollay.horvath@gmail.com> * Copyright (C) 2018, Adam Reichold <adam.reichold@t-online.de> @@ -498,6 +498,9 @@ std::vector<std::string> image::supported_image_formats() */ image& image::operator=(const image &pt) { + if (this == &pt) + return *this; + if (pt.d) { ++pt.d->ref; } diff --git a/qt5/src/poppler-outline.cc b/qt5/src/poppler-outline.cc index dd452b47..1c7e4a3d 100644 --- a/qt5/src/poppler-outline.cc +++ b/qt5/src/poppler-outline.cc @@ -44,6 +44,9 @@ OutlineItem::OutlineItem(const OutlineItem &other) : m_data{new OutlineItemData{ OutlineItem &OutlineItem::operator=(const OutlineItem &other) { + if (this == &other) + return *this; + auto *data = new OutlineItemData{*other.m_data}; qSwap(m_data, data); delete data; |