From: Matt Caswell Date: Mon, 5 Aug 2019 12:37:05 +0000 (+0100) Subject: Don't set ctx->cipher until after a successful fetch X-Git-Tag: openssl-3.0.0-alpha1~1664 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=7f612b1f04ee0cf72d6af292a76f43dd74e88af9;p=oweals%2Fopenssl.git Don't set ctx->cipher until after a successful fetch If an implict EVP_CIPHER_fetch fails then ctx->cipher should not be set otherwise strange things will happen when trying to free the ctx. Reviewed-by: Shane Lontis (Merged from https://github.com/openssl/openssl/pull/9531) --- diff --git a/crypto/evp/evp_enc.c b/crypto/evp/evp_enc.c index 87c7bb0995..31e15a63c2 100644 --- a/crypto/evp/evp_enc.c +++ b/crypto/evp/evp_enc.c @@ -197,9 +197,7 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ctx->flags = flags; } - if (cipher != NULL) - ctx->cipher = cipher; - else + if (cipher == NULL) cipher = ctx->cipher; if (cipher->prov == NULL) {