summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2012-06-30 16:12:48 +0200
committerDavid Tardon <dtardon@redhat.com>2012-06-30 16:12:48 +0200
commit042eb000a66bf2e3019e8eb83e09906cc2f1c745 (patch)
tree74a6fffaff64ef50126e2d513a3c194e5b76fec2
parentba5f4ec35d86f909dff7b2c79cec7150419b2866 (diff)
coverity: protect against self-assignment
-rw-r--r--src/lib/VSDXFieldList.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/lib/VSDXFieldList.cpp b/src/lib/VSDXFieldList.cpp
index 3ffb15e..3674019 100644
--- a/src/lib/VSDXFieldList.cpp
+++ b/src/lib/VSDXFieldList.cpp
@@ -200,13 +200,16 @@ libvisio::VSDXFieldList::VSDXFieldList(const libvisio::VSDXFieldList &fieldList)
libvisio::VSDXFieldList &libvisio::VSDXFieldList::operator=(const libvisio::VSDXFieldList &fieldList)
{
- clear();
- std::map<unsigned, VSDXFieldListElement *>::const_iterator iter = fieldList.m_elements.begin();
- for (; iter != fieldList.m_elements.end(); ++iter)
- m_elements[iter->first] = iter->second->clone();
- m_elementsOrder = fieldList.m_elementsOrder;
- m_id = fieldList.m_id;
- m_level = fieldList.m_level;
+ if (this != &fieldList)
+ {
+ clear();
+ std::map<unsigned, VSDXFieldListElement *>::const_iterator iter = fieldList.m_elements.begin();
+ for (; iter != fieldList.m_elements.end(); ++iter)
+ m_elements[iter->first] = iter->second->clone();
+ m_elementsOrder = fieldList.m_elementsOrder;
+ m_id = fieldList.m_id;
+ m_level = fieldList.m_level;
+ }
return *this;
}