mirror of https://github.com/OpenTTD/OpenTTD
(svn r10647) -Fix: AutoPtrT::operator =() didn't delete old object
parent
43ddd64817
commit
d3c20d65bd
|
@ -81,8 +81,16 @@ public:
|
||||||
/** assignment operator */
|
/** assignment operator */
|
||||||
FORCEINLINE AutoPtrT& operator = (const AutoPtrT& src)
|
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;
|
m_p = src.m_p;
|
||||||
|
|
||||||
if (m_p != NULL) src.m_p = NULL;
|
if (m_p != NULL) src.m_p = NULL;
|
||||||
|
|
||||||
|
if (p != NULL) {
|
||||||
|
/* Now we can safely delete the old one. */
|
||||||
|
delete p;
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue