mirror of
https://github.com/znc/znc.git
synced 2026-08-07 09:22:55 +02:00
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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user