summaryrefslogtreecommitdiff
path: root/smartptr.h
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2010-06-18 07:06:59 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2010-06-18 07:06:59 +0000
commite562437c88d18d206d079aa0ed07f5be57203a4a (patch)
tree2c3909fc3181e50ef34814d62769b02277bc13a5 /smartptr.h
parent70a991f0023a3bd23bfd6ffd0b665f1dbed701bf (diff)
downloadcryptopp-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 'smartptr.h')
-rw-r--r--smartptr.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/smartptr.h b/smartptr.h
index 6b4040e..a0a727e 100644
--- a/smartptr.h
+++ b/smartptr.h
@@ -9,8 +9,8 @@ NAMESPACE_BEGIN(CryptoPP)
template <class T> class simple_ptr
{
public:
- simple_ptr() : m_p(NULL) {}
- ~simple_ptr() {delete m_p;}
+ simple_ptr(T *p = NULL) : m_p(p) {}
+ ~simple_ptr() {delete m_p; m_p = NULL;} // set m_p to NULL so double destruction (which might occur in Singleton) will be harmless
T *m_p;
};