From 0bf2abaa4c4c40775a9b8d3f4b852158cc8f840e Mon Sep 17 00:00:00 2001 From: orignal Date: Sat, 2 Apr 2016 08:57:35 -0400 Subject: [PATCH] fixed race condition at startup --- Signature.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Signature.cpp b/Signature.cpp index 13612327..11fc8600 100644 --- a/Signature.cpp +++ b/Signature.cpp @@ -435,8 +435,13 @@ namespace crypto std::unique_ptr& GetEd25519 () { if (!g_Ed25519) - g_Ed25519.reset (new Ed25519()); - + { + auto c = new Ed25519(); + if (!g_Ed25519) // make sure it was not created already + g_Ed25519.reset (c); + else + delete c; + } return g_Ed25519; }