diff options
author | Tomas Mraz <tomas@openssl.org> | 2023-09-26 17:39:50 +0200 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2023-10-05 20:07:41 +0200 |
commit | 02ddffc2c9b3a5f27d9d1b393b6c3fa1d97b9eed (patch) | |
tree | 29530576d39ecc9d3044d4747ba9bebb43d949b7 | |
parent | e941f3fcae07f5059a654c392fed4063975c8ea2 (diff) |
Optimize out unneeded up_ref/free of EVP_CIPHER
Fixes #22189
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22198)
(cherry picked from commit 8ed76c62b5d3214e807e684c06efd69c6471c800)
-rw-r--r-- | crypto/evp/evp_enc.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/crypto/evp/evp_enc.c b/crypto/evp/evp_enc.c index 0ebfbdaf22..fec889d2fe 100644 --- a/crypto/evp/evp_enc.c +++ b/crypto/evp/evp_enc.c @@ -197,7 +197,12 @@ static int evp_cipher_init_internal(EVP_CIPHER_CTX *ctx, #endif } - if (cipher->prov != NULL) { + if (!ossl_assert(cipher->prov != NULL)) { + ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR); + return 0; + } + + if (cipher != ctx->fetched_cipher) { if (!EVP_CIPHER_up_ref((EVP_CIPHER *)cipher)) { ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR); return 0; |