aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/rsa
diff options
context:
space:
mode:
authorPauli <pauli@openssl.org>2023-07-02 17:19:17 +1000
committerPauli <pauli@openssl.org>2023-07-05 08:34:00 +1000
commit97beb77f319f119957235233396627bb22283da0 (patch)
treee2c58f0b0e46f90ca732da86e9a315a781622ed9 /crypto/rsa
parent52c362b3fe5ab9b1c44ec560820b242eb3df0e3b (diff)
downloadopenssl-97beb77f319f119957235233396627bb22283da0.tar.gz
fix memory allocation and reference counting issues
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Kurt Roeckx <kurt@roeckx.be> (Merged from https://github.com/openssl/openssl/pull/21341)
Diffstat (limited to 'crypto/rsa')
-rw-r--r--crypto/rsa/rsa_lib.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/crypto/rsa/rsa_lib.c b/crypto/rsa/rsa_lib.c
index c591b8941d..1601e92ddb 100644
--- a/crypto/rsa/rsa_lib.c
+++ b/crypto/rsa/rsa_lib.c
@@ -86,8 +86,11 @@ static RSA *rsa_new_intern(ENGINE *engine, OSSL_LIB_CTX *libctx)
return NULL;
}
- if (!CRYPTO_NEW_REF(&ret->references, 1))
- goto err;
+ if (!CRYPTO_NEW_REF(&ret->references, 1)) {
+ CRYPTO_THREAD_lock_free(ret->lock);
+ OPENSSL_free(ret);
+ return NULL;
+ }
ret->libctx = libctx;
ret->meth = RSA_get_default_method();