src/misc/autoptr.hpp
changeset 7795 fe7798d24140
parent 7794 ccc691b566eb
--- a/src/misc/autoptr.hpp	Sat Jul 21 13:45:15 2007 +0000
+++ b/src/misc/autoptr.hpp	Sat Jul 21 14:01:12 2007 +0000
@@ -81,8 +81,16 @@
 	/** 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;
 	}