diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-04-08 14:38:24 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-04-08 14:38:24 +0000 |
commit | 9aeee8aa629c69e34aa65fb30c4b1ce1e6049ced (patch) | |
tree | 4045042ed7c08398ed0d8fdebd80b81f4a88a73c /document | |
parent | d59924fdb0ebad31d5704314ceb38322461a406f (diff) |
Guard against self assignment.
Diffstat (limited to 'document')
-rw-r--r-- | document/src/vespa/document/fieldvalue/variablemap.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/document/src/vespa/document/fieldvalue/variablemap.cpp b/document/src/vespa/document/fieldvalue/variablemap.cpp index be973782eb3..a323ea35851 100644 --- a/document/src/vespa/document/fieldvalue/variablemap.cpp +++ b/document/src/vespa/document/fieldvalue/variablemap.cpp @@ -33,9 +33,11 @@ IndexValue::IndexValue(const IndexValue & rhs) : key(rhs.key ? rhs.key->clone() : nullptr) {} IndexValue & IndexValue::operator = (const IndexValue & rhs) { - IndexValue tmp(rhs); - std::swap(index, tmp.index); - std::swap(key, tmp.key); + if (this != & rhs) { + IndexValue tmp(rhs); + std::swap(index, tmp.index); + std::swap(key, tmp.key); + } return *this; } |