summaryrefslogtreecommitdiff
path: root/src/misc
diff options
context:
space:
mode:
authorKUDr <kudr@openttd.org>2007-07-21 14:01:12 +0000
committerKUDr <kudr@openttd.org>2007-07-21 14:01:12 +0000
commitd3c20d65bd04925822595a6cf27208b8a658f91c (patch)
treea49dc8df36f06910cc1c1a2b3853ec1b21a0598a /src/misc
parent43ddd64817cde65142b9eaba230f1414f8c3fa66 (diff)
downloadopenttd-d3c20d65bd04925822595a6cf27208b8a658f91c.tar.xz
(svn r10647) -Fix: AutoPtrT::operator =() didn't delete old object
Diffstat (limited to 'src/misc')
-rw-r--r--src/misc/autoptr.hpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/misc/autoptr.hpp b/src/misc/autoptr.hpp
index edb7c10c6..8b0d920f5 100644
--- a/src/misc/autoptr.hpp
+++ b/src/misc/autoptr.hpp
@@ -81,8 +81,16 @@ public:
/** assignment operator */
FORCEINLINE AutoPtrT& operator = (const AutoPtrT& src)
{
+ /* Save original pointer and replace it with the given one to avoid recursive calls. */
+ T* p = m_p;
m_p = src.m_p;
+
if (m_p != NULL) src.m_p = NULL;
+
+ if (p != NULL) {
+ /* Now we can safely delete the old one. */
+ delete p;
+ }
return *this;
}