Thread-safety fixes
[openssl.git] / crypto / err / err.c
index 84741326ac94ad7566b4dbcbe7fb4e6aad2a4141..3367a75d99abed655f8ffaed336aad0aa0c8edd4 100644 (file)
@@ -550,9 +550,20 @@ static void build_SYS_str_reasons(void)
        int i;
        static int init = 1;
 
        int i;
        static int init = 1;
 
-       if (!init) return;
-
+       CRYPTO_r_lock(CRYPTO_LOCK_ERR);
+       if (!init)
+               {
+               CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
+               return;
+               }
+       
+       CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
        CRYPTO_w_lock(CRYPTO_LOCK_ERR);
        CRYPTO_w_lock(CRYPTO_LOCK_ERR);
+       if (!init)
+               {
+               CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
+               return;
+               }
 
        for (i = 1; i <= NUM_SYS_STR_REASONS; i++)
                {
 
        for (i = 1; i <= NUM_SYS_STR_REASONS; i++)
                {