Ensure all locks are properly cleaned up
[openssl.git] / crypto / err / err.c
index 3ee4e86..aff3ae5 100644 (file)
 #include <string.h>
 #include <internal/cryptlib_int.h>
 #include <internal/threads.h>
+#include <internal/err.h>
 #include <openssl/lhash.h>
 #include <openssl/crypto.h>
 #include <openssl/buffer.h>
@@ -389,9 +390,13 @@ static void ERR_STATE_free(ERR_STATE *s)
 
 static void do_err_strings_init(void)
 {
-    CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);
     err_string_lock = CRYPTO_THREAD_lock_new();
-    CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
+}
+
+void err_cleanup(void)
+{
+    CRYPTO_THREAD_lock_free(err_string_lock);
+    err_string_lock = NULL;
 }
 
 void ERR_load_ERR_strings(void)