Following the license change, modify the boilerplates in crypto/engine/
[openssl.git] / crypto / engine / eng_init.c
index c51a38dac0cfdefa33e3f885a4fb2d2246828fcd..6d74a2ddb1fcb8a4252a636b563fb3c5dab49ce3 100644 (file)
@@ -1,12 +1,13 @@
 /*
- * Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2001-2017 The OpenSSL Project Authors. All Rights Reserved.
  *
- * Licensed under the OpenSSL license (the "License").  You may not use
+ * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
  * in the file LICENSE in the source distribution or at
  * https://www.openssl.org/source/license.html
  */
 
+#include "e_os.h"
 #include "eng_int.h"
 
 /*
@@ -80,7 +81,10 @@ int ENGINE_init(ENGINE *e)
         ENGINEerr(ENGINE_F_ENGINE_INIT, ERR_R_PASSED_NULL_PARAMETER);
         return 0;
     }
-    CRYPTO_THREAD_run_once(&engine_lock_init, do_engine_lock_init);
+    if (!RUN_ONCE(&engine_lock_init, do_engine_lock_init)) {
+        ENGINEerr(ENGINE_F_ENGINE_INIT, ERR_R_MALLOC_FAILURE);
+        return 0;
+    }
     CRYPTO_THREAD_write_lock(global_engine_lock);
     ret = engine_unlocked_init(e);
     CRYPTO_THREAD_unlock(global_engine_lock);