aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMax Horn2007-03-12 22:34:29 +0000
committerMax Horn2007-03-12 22:34:29 +0000
commit30e975f9db056cd58728ebdc79689e41eb27f1d1 (patch)
tree1647771a0a356808f9d10aafcfd85ef2b8298c78 /common
parent689ea77c0d8be927d2d5c9874239e444267a4999 (diff)
downloadscummvm-rg350-30e975f9db056cd58728ebdc79689e41eb27f1d1.tar.gz
scummvm-rg350-30e975f9db056cd58728ebdc79689e41eb27f1d1.tar.bz2
scummvm-rg350-30e975f9db056cd58728ebdc79689e41eb27f1d1.zip
Protect Array<> and HashMap<> instances against self assignments
svn-id: r26115
Diffstat (limited to 'common')
-rw-r--r--common/array.h3
-rw-r--r--common/hashmap.h3
2 files changed, 6 insertions, 0 deletions
diff --git a/common/array.h b/common/array.h
index 95f3c90ebe..d0be7fa194 100644
--- a/common/array.h
+++ b/common/array.h
@@ -100,6 +100,9 @@ public:
}
Array<T>& operator =(const Array<T>& array) {
+ if (this == &array)
+ return *this;
+
if (_data)
delete [] _data;
_size = array._size;
diff --git a/common/hashmap.h b/common/hashmap.h
index b5b2bb922b..982e3df70f 100644
--- a/common/hashmap.h
+++ b/common/hashmap.h
@@ -155,6 +155,9 @@ public:
~HashMap();
HM_t &operator =(const HM_t &map) {
+ if (this == &map)
+ return *this;
+
// Remove the previous content and ...
clear();
delete[] _arr;