PR: 2124
[openssl.git] / crypto / rsa / rsa_lib.c
index cf35c0d10bd9086f56f8201f40e17819e40d8601..de45088d761d2d04f7e89f978bbc83cca7c3ea0d 100644 (file)
@@ -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
@@ -417,11 +426,13 @@ BN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *in_ctx)
                RSAerr(RSA_F_RSA_SETUP_BLINDING, ERR_R_BN_LIB);
                goto err;
                }
-       BN_BLINDING_set_thread(ret);
+       CRYPTO_THREADID_current(BN_BLINDING_thread_id(ret));
 err:
        BN_CTX_end(ctx);
        if (in_ctx == NULL)
                BN_CTX_free(ctx);
+       if(rsa->e == NULL)
+               BN_free(e);
 
        return ret;
 }