Skip to content

Commit

Permalink
Optimize out unneeded up_ref/free of EVP_CIPHER
Browse files Browse the repository at this point in the history
Fixes #22189

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from #22198)

(cherry picked from commit 8ed76c6)
  • Loading branch information
t8m committed Oct 5, 2023
1 parent 8110612 commit 1c01dbc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crypto/evp/evp_enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1c01dbc

Please sign in to comment.