summaryrefslogtreecommitdiff
path: root/crypto/evp/digest.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/evp/digest.c')
-rw-r--r--crypto/evp/digest.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/crypto/evp/digest.c b/crypto/evp/digest.c
index e055c70a5f..5de5a9014d 100644
--- a/crypto/evp/digest.c
+++ b/crypto/evp/digest.c
@@ -230,11 +230,12 @@ static int evp_md_init_internal(EVP_MD_CTX *ctx, const EVP_MD *type,
# endif
#endif
|| (ctx->flags & EVP_MD_CTX_FLAG_NO_INIT) != 0
- || type->origin == EVP_ORIG_METH) {
+ || (type != NULL && type->origin == EVP_ORIG_METH)
+ || (type == NULL && ctx->digest != NULL
+ && ctx->digest->origin == EVP_ORIG_METH)) {
/* If we were using provided hash before, cleanup algctx */
if (!evp_md_ctx_free_algctx(ctx))
return 0;
-
if (ctx->digest == ctx->fetched_digest)
ctx->digest = NULL;
EVP_MD_free(ctx->fetched_digest);