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:31 +0200 |
commit | 1c01dbcbebc08d629d02326d941b8491ae99597d (patch) | |
tree | 9cb018c75bfe3d5daf8c72426e017e3301dafd1a | |
parent | 8110612b21a6ceb6ae9291067142594b2a11f01d (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 b178d10864..d2ed3fd378 100644 --- a/crypto/evp/evp_enc.c +++ b/crypto/evp/evp_enc.c @@ -192,7 +192,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; |