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 <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/9531)
This commit is contained in:
Matt Caswell 2019-08-05 13:37:05 +01:00
parent e9c116ebcb
commit 7f612b1f04

View file

@ -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) {