summaryrefslogtreecommitdiffstats
path: root/crypto/rsa/rsa_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/rsa/rsa_lib.c')
-rw-r--r--crypto/rsa/rsa_lib.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/crypto/rsa/rsa_lib.c b/crypto/rsa/rsa_lib.c
index e334e506fb..de45088d76 100644
--- a/crypto/rsa/rsa_lib.c
+++ b/crypto/rsa/rsa_lib.c
@@ -182,7 +182,16 @@ RSA *RSA_new_method(ENGINE *engine)
ret->mt_blinding=NULL;
ret->bignum_data=NULL;
ret->flags=ret->meth->flags;
- CRYPTO_new_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data);
+ if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data))
+ {
+#ifndef OPENSSL_NO_ENGINE
+ if (ret->engine)
+ ENGINE_finish(ret->engine);
+#endif
+ OPENSSL_free(ret);
+ return(NULL);
+ }
+
if ((ret->meth->init != NULL) && !ret->meth->init(ret))
{
#ifndef OPENSSL_NO_ENGINE