From 7f612b1f04ee0cf72d6af292a76f43dd74e88af9 Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Mon, 5 Aug 2019 13:37:05 +0100 Subject: [PATCH] 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) --- crypto/evp/evp_enc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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) { -- 2.25.1