From d3c20d65bd04925822595a6cf27208b8a658f91c Mon Sep 17 00:00:00 2001 From: KUDr Date: Sat, 21 Jul 2007 14:01:12 +0000 Subject: [PATCH] (svn r10647) -Fix: AutoPtrT::operator =() didn't delete old object --- src/misc/autoptr.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/misc/autoptr.hpp b/src/misc/autoptr.hpp index edb7c10c68..8b0d920f5a 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; }