From 166d98c05e8b9c16f9e1a1018f84c84d571e134d Mon Sep 17 00:00:00 2001 From: sebastinas Date: Wed, 11 Mar 2009 14:32:12 +0000 Subject: [PATCH] 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 --- Utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Utils.h b/Utils.h index 2f251009..e0ac0098 100644 --- a/Utils.h +++ b/Utils.h @@ -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: