diff options
author | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2010-06-18 07:06:59 +0000 |
---|---|---|
committer | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2010-06-18 07:06:59 +0000 |
commit | e562437c88d18d206d079aa0ed07f5be57203a4a (patch) | |
tree | 2c3909fc3181e50ef34814d62769b02277bc13a5 /secblock.h | |
parent | 70a991f0023a3bd23bfd6ffd0b665f1dbed701bf (diff) | |
download | cryptopp-e562437c88d18d206d079aa0ed07f5be57203a4a.tar.gz |
fix possible race condition in Singleton::Ref()
tolerate double destruction of Singleton and g_nullNameValuePairs
fix #include of standard headers
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@488 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'secblock.h')
-rw-r--r-- | secblock.h | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -9,8 +9,6 @@ #if defined(CRYPTOPP_MEMALIGN_AVAILABLE) || defined(CRYPTOPP_MM_MALLOC_AVAILABLE) || defined(QNX) #include <malloc.h> -#else - #include <stdlib.h> #endif NAMESPACE_BEGIN(CryptoPP) @@ -352,8 +350,11 @@ public: //! copy contents and size from another SecBlock void Assign(const SecBlock<T, A> &t) { - New(t.m_size); - memcpy_s(m_ptr, m_size*sizeof(T), t.m_ptr, m_size*sizeof(T)); + if (this != &t) + { + New(t.m_size); + memcpy_s(m_ptr, m_size*sizeof(T), t.m_ptr, m_size*sizeof(T)); + } } SecBlock<T, A>& operator=(const SecBlock<T, A> &t) |