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