Thread-safety fixes
[openssl.git] / crypto / err / err.c
index 53687d79ab6f4c98d2ba9509bcb2ab766caf777f..8875beacffebdafd466bdc3bade59be274f14f35 100644 (file)
@@ -549,9 +549,20 @@ static void build_SYS_str_reasons()
        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);
+       if (!init)
+               {
+               CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
+               return;
+               }
 
        for (i = 1; i <= NUM_SYS_STR_REASONS; i++)
                {