diff options
Diffstat (limited to 'crypto/evp')
-rw-r--r-- | crypto/evp/p_lib.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c index 46883255c6..ed228a1bd4 100644 --- a/crypto/evp/p_lib.c +++ b/crypto/evp/p_lib.c @@ -1973,6 +1973,8 @@ void *evp_pkey_export_to_provider(EVP_PKEY *pk, OSSL_LIB_CTX *libctx, #ifndef FIPS_MODULE int evp_pkey_copy_downgraded(EVP_PKEY **dest, const EVP_PKEY *src) { + EVP_PKEY *allocpkey = NULL; + if (!ossl_assert(dest != NULL)) return 0; @@ -2003,7 +2005,7 @@ int evp_pkey_copy_downgraded(EVP_PKEY **dest, const EVP_PKEY *src) /* Make sure we have a clean slate to copy into */ if (*dest == NULL) { - *dest = EVP_PKEY_new(); + allocpkey = *dest = EVP_PKEY_new(); if (*dest == NULL) { ERR_raise(ERR_LIB_EVP, ERR_R_MALLOC_FAILURE); return 0; @@ -2052,6 +2054,10 @@ int evp_pkey_copy_downgraded(EVP_PKEY **dest, const EVP_PKEY *src) } } + if (allocpkey != NULL) { + EVP_PKEY_free(allocpkey); + *dest = NULL; + } return 0; } |