From aaa5695ae26aea31b7e401312abbfa949995b954 Mon Sep 17 00:00:00 2001 From: Michael Baentsch <57787676+baentsch@users.noreply.github.com> Date: Thu, 18 May 2023 23:22:37 +0200 Subject: [PATCH] protect ossl cleanup from multithreading errors (#1472) --- src/common/common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/common.c b/src/common/common.c index 011f35cac9..ceb1bf38b5 100644 --- a/src/common/common.c +++ b/src/common/common.c @@ -24,6 +24,7 @@ #if defined(OQS_USE_OPENSSL) #include <openssl/evp.h> #include "ossl_helpers.h" +CRYPTO_ONCE OQS_ONCE_STATIC_FREE; #endif /* Identifying the CPU is expensive so we cache the results in cpu_ext_data */ @@ -216,7 +217,7 @@ OQS_API const char *OQS_version(void) { OQS_API void OQS_destroy(void) { #if defined(OQS_USE_OPENSSL) - oqs_free_ossl_objects(); + CRYPTO_THREAD_run_once(&OQS_ONCE_STATIC_FREE, oqs_free_ossl_objects); #endif return; }