From: <seb...@us...> - 2009-03-11 14:32:33
|
Revision: 1422 http://znc.svn.sourceforge.net/znc/?rev=1422&view=rev Author: sebastinas Date: 2009-03-11 14:32:12 +0000 (Wed, 11 Mar 2009) Log Message: ----------- Fix for CSmartPtr::GetCount Since CSmartPtr::GetCount returns a pointer to unsigned int it's possible to manually change the reference count from outside. Increasing the reference count will result in a memory leak and decreasing will produce undefined behaviour. GetCount now returns a pointer to const unsigned int to fix this. Modified Paths: -------------- trunk/Utils.h Modified: trunk/Utils.h =================================================================== --- trunk/Utils.h 2009-03-10 19:36:24 UTC (rev 1421) +++ trunk/Utils.h 2009-03-11 14:32:12 UTC (rev 1422) @@ -347,7 +347,7 @@ } m_pType = &(*CopyFrom); // Make our pointers reference the same raw pointer and counter - m_puCount = CopyFrom.GetCount(); + m_puCount = CopyFrom.m_puCount; if (m_pType) { // If we now point to something valid, increment the counter assert(m_puCount); @@ -413,7 +413,7 @@ // Getters T* GetPtr() const { return m_pType; } - unsigned int* GetCount() const { return m_puCount; } + const unsigned int* GetCount() const { return m_puCount; } unsigned int GetClientCount() const { return (m_puCount) ? *m_puCount : 0; } // !Getters private: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |