ip = &ex_data[class_index];
CRYPTO_THREAD_write_lock(ex_data_lock);
- if (ip->meth == NULL) {
- ip->meth = sk_EX_CALLBACK_new_null();
- /* We push an initial value on the stack because the SSL
- * "app_data" routines use ex_data index zero. See RT 3710. */
- if (ip->meth == NULL
- || !sk_EX_CALLBACK_push(ip->meth, NULL)) {
- CRYPTOerr(CRYPTO_F_GET_AND_LOCK, ERR_R_MALLOC_FAILURE);
- CRYPTO_THREAD_unlock(ex_data_lock);
- return NULL;
- }
- }
return ip;
}
if (ip == NULL)
return -1;
+
+ if (ip->meth == NULL) {
+ ip->meth = sk_EX_CALLBACK_new_null();
+ /* We push an initial value on the stack because the SSL
+ * "app_data" routines use ex_data index zero. See RT 3710. */
+ if (ip->meth == NULL
+ || !sk_EX_CALLBACK_push(ip->meth, NULL)) {
+ CRYPTOerr(CRYPTO_F_GET_AND_LOCK, ERR_R_MALLOC_FAILURE);
+ goto err;
+ }
+ }
+
a = (EX_CALLBACK *)OPENSSL_malloc(sizeof(*a));
if (a == NULL) {
CRYPTOerr(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX, ERR_R_MALLOC_FAILURE);
"RAND_cleanup()\n");
#endif
- CRYPTO_cleanup_all_ex_data();
- EVP_cleanup();
- CONF_modules_free();
+/*
+ * Note that cleanup order is important.
+ * For example, ENGINEs use CRYPTO_EX_DATA and therefore, must be cleaned up
+ * before the ex data handlers are wiped in CRYPTO_cleanup_all_ex_data().
+ */
#ifndef OPENSSL_NO_ENGINE
ENGINE_cleanup();
#endif
+ CRYPTO_cleanup_all_ex_data();
+ EVP_cleanup();
+ CONF_modules_free();
RAND_cleanup();
base_inited = 0;
}
return 1;
}
-
-