Skip to content

Commit b020cf2

Browse files
Tsuk1hanikias
authored andcommitted
cpp: Add this comparison to operator= copy assign
1 parent 18e5b22 commit b020cf2

File tree

10 files changed

+20
-0
lines changed

10 files changed

+20
-0
lines changed

src/Array.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ Array::Array(const PList::Array& a) : Structure(a.GetParent())
6262

6363
Array& Array::operator=(const PList::Array& a)
6464
{
65+
if (this == &a) return *this;
66+
6567
plist_free(_node);
6668
for (size_t it = 0; it < _array.size(); it++) {
6769
delete _array.at(it);

src/Boolean.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ Boolean::Boolean(const PList::Boolean& b) : Node(PLIST_BOOLEAN)
4040

4141
Boolean& Boolean::operator=(const PList::Boolean& b)
4242
{
43+
if (this == &b) return *this;
44+
4345
plist_free(_node);
4446
_node = plist_copy(b.GetPlist());
4547
return *this;

src/Data.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ Data::Data(const PList::Data& d) : Node(PLIST_DATA)
4040

4141
Data& Data::operator=(const PList::Data& b)
4242
{
43+
if (this == &b) return *this;
44+
4345
plist_free(_node);
4446
_node = plist_copy(b.GetPlist());
4547
return *this;

src/Date.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ Date::Date(const PList::Date& d) : Node(PLIST_DATE)
4040

4141
Date& Date::operator=(const PList::Date& d)
4242
{
43+
if (this == &d) return *this;
44+
4345
plist_free(_node);
4446
_node = plist_copy(d.GetPlist());
4547
return *this;

src/Dictionary.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ Dictionary::Dictionary(const PList::Dictionary& d) : Structure(d.GetParent())
6565

6666
Dictionary& Dictionary::operator=(const PList::Dictionary& d)
6767
{
68+
if (this == &d) return *this;
69+
6870
for (Dictionary::iterator it = _map.begin(); it != _map.end(); it++)
6971
{
7072
plist_free(it->second->GetPlist());

src/Integer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ Integer::Integer(const PList::Integer& i) : Node(PLIST_INT)
4141

4242
Integer& Integer::operator=(const PList::Integer& i)
4343
{
44+
if (this == &i) return *this;
45+
4446
plist_free(_node);
4547
_node = plist_copy(i.GetPlist());
4648
return *this;

src/Key.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ Key::Key(const PList::Key& k) : Node(PLIST_INT)
4040

4141
Key& Key::operator=(const PList::Key& k)
4242
{
43+
if (this == &k) return *this;
44+
4345
plist_free(_node);
4446
_node = plist_copy(k.GetPlist());
4547
return *this;

src/Real.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ Real::Real(const PList::Real& d) : Node(PLIST_INT)
3939

4040
Real& Real::operator=(const PList::Real& d)
4141
{
42+
if (this == &d) return *this;
43+
4244
plist_free(_node);
4345
_node = plist_copy(d.GetPlist());
4446
return *this;

src/String.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ String::String(const PList::String& s) : Node(PLIST_INT)
4040

4141
String& String::operator=(const PList::String& s)
4242
{
43+
if (this == &s) return *this;
44+
4345
plist_free(_node);
4446
_node = plist_copy(s.GetPlist());
4547
return *this;

src/Uid.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ Uid::Uid(const PList::Uid& i) : Node(PLIST_UID)
4040

4141
Uid& Uid::operator=(const PList::Uid& i)
4242
{
43+
if (this == &i) return *this;
44+
4345
plist_free(_node);
4446
_node = plist_copy(i.GetPlist());
4547
return *this;

0 commit comments

Comments
 (0)