diff options
author | Tomas Mraz <tomas@openssl.org> | 2021-07-21 18:45:01 +0200 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2021-07-23 09:06:18 +0200 |
commit | 40184c96103a388209939c1c19920971c05bb78c (patch) | |
tree | 00b7047410a88afc8a67375d2a46a9fa0c955de1 /crypto/dsa | |
parent | a983764e17551b2988bd684279ac9e9077d84601 (diff) |
DSA/RSA_print(): Fix potential memory leak
Fixes #10777
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16130)
Diffstat (limited to 'crypto/dsa')
-rw-r--r-- | crypto/dsa/dsa_prn.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/crypto/dsa/dsa_prn.c b/crypto/dsa/dsa_prn.c index c5ec7d5dfe..6f001a50f0 100644 --- a/crypto/dsa/dsa_prn.c +++ b/crypto/dsa/dsa_prn.c @@ -55,9 +55,11 @@ int DSA_print(BIO *bp, const DSA *x, int off) EVP_PKEY *pk; int ret; pk = EVP_PKEY_new(); - if (pk == NULL || !EVP_PKEY_set1_DSA(pk, (DSA *)x)) + if (pk == NULL) return 0; - ret = EVP_PKEY_print_private(bp, pk, off, NULL); + ret = EVP_PKEY_set1_DSA(pk, (DSA *)x); + if (ret) + ret = EVP_PKEY_print_private(bp, pk, off, NULL); EVP_PKEY_free(pk); return ret; } @@ -67,9 +69,11 @@ int DSAparams_print(BIO *bp, const DSA *x) EVP_PKEY *pk; int ret; pk = EVP_PKEY_new(); - if (pk == NULL || !EVP_PKEY_set1_DSA(pk, (DSA *)x)) + if (pk == NULL) return 0; - ret = EVP_PKEY_print_params(bp, pk, 4, NULL); + ret = EVP_PKEY_set1_DSA(pk, (DSA *)x); + if (ret) + ret = EVP_PKEY_print_params(bp, pk, 4, NULL); EVP_PKEY_free(pk); return ret; } |