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.

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1422 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
sebastinas
2009-03-11 14:32:12 +00:00
parent 0a96b3d223
commit 166d98c05e
+2 -2
View File
@@ -347,7 +347,7 @@ public:
}
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 @@ public:
// 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: