Ensure all locks are properly cleaned up
[openssl.git] / crypto / init.c
index d9f40001a2491a798d0304bb258377e1df4d80db..48f74c496c0c73b9490fe2f8aca140cd122824e3 100644 (file)
@@ -67,6 +67,7 @@
 #include <internal/engine.h>
 #include <internal/comp.h>
 #include <internal/err.h>
+#include <internal/err_int.h>
 #include <internal/objects.h>
 #include <stdlib.h>
 #include <assert.h>
@@ -466,19 +467,25 @@ void OPENSSL_cleanup(void)
                     "crypto_cleanup_all_ex_data_int()\n");
     fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
                     "bio_sock_cleanup_int()\n");
+    fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
+                    "bio_cleanup()\n");
     fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
                     "evp_cleanup_int()\n");
     fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
                     "obj_cleanup_int()\n");
+    fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
+                    "err_cleanup()\n");
 #endif
     /*
      * Note that cleanup order is important:
-     * - rand_cleanup_int could call an ENINGE's RAND cleanup function so
+     * - rand_cleanup_int could call an ENGINE's RAND cleanup function so
      * must be called before engine_cleanup_int()
      * - ENGINEs use CRYPTO_EX_DATA and therefore, must be cleaned up
      * before the ex data handlers are wiped in CRYPTO_cleanup_all_ex_data().
      * - conf_modules_free_int() can end up in ENGINE code so must be called
      * before engine_cleanup_int()
+     * - ENGINEs and additional EVP algorithms might use added OIDs names so
+     * obj_cleanup_int() must be called last
      */
     rand_cleanup_int();
     conf_modules_free_int();
@@ -486,11 +493,11 @@ void OPENSSL_cleanup(void)
     engine_cleanup_int();
 #endif
     crypto_cleanup_all_ex_data_int();
-#ifndef OPENSSL_NO_SOCK
-    bio_sock_cleanup_int();
-#endif
+    bio_cleanup();
     evp_cleanup_int();
     obj_cleanup_int();
+    err_cleanup();
+
     base_inited = 0;
 }