diff options
author | Rich Salz <rsalz@akamai.com> | 2016-02-25 12:09:06 -0500 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2016-02-25 15:19:42 -0500 |
commit | 7c96dbcdab959fef74c4caae63cdebaa354ab252 (patch) | |
tree | af59789bb5bc85efd7e700d657db004910f8ba64 /crypto/evp/digest.c | |
parent | 07b3ce8f8029f647c1babf0d8a03599885e7e284 (diff) | |
download | openssl-7c96dbcdab959fef74c4caae63cdebaa354ab252.tar.gz |
GH715: ENGINE_finish can take NULL
Simplifies calling code. Also fixed up any !ptr tests that were
nearby, turning them into NULL tests.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto/evp/digest.c')
-rw-r--r-- | crypto/evp/digest.c | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/crypto/evp/digest.c b/crypto/evp/digest.c index f7e82db6dd..f89f1c8447 100644 --- a/crypto/evp/digest.c +++ b/crypto/evp/digest.c @@ -137,12 +137,7 @@ int EVP_MD_CTX_reset(EVP_MD_CTX *ctx) } EVP_PKEY_CTX_free(ctx->pctx); #ifndef OPENSSL_NO_ENGINE - if (ctx->engine) - /* - * The EVP_MD we used belongs to an ENGINE, release the functional - * reference we held for this reason. - */ - ENGINE_finish(ctx->engine); + ENGINE_finish(ctx->engine); #endif memset(ctx, 0, sizeof(*ctx)); @@ -187,21 +182,21 @@ int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl) * previous check attempted to avoid this if the same ENGINE and * EVP_MD could be used). */ - if (ctx->engine) - ENGINE_finish(ctx->engine); - if (impl) { + ENGINE_finish(ctx->engine); + if (impl != NULL) { if (!ENGINE_init(impl)) { EVPerr(EVP_F_EVP_DIGESTINIT_EX, EVP_R_INITIALIZATION_ERROR); return 0; } - } else + } else { /* Ask if an ENGINE is reserved for this job */ impl = ENGINE_get_digest_engine(type->type); - if (impl) { + } + if (impl != NULL) { /* There's an ENGINE for this job ... (apparently) */ const EVP_MD *d = ENGINE_get_digest(impl, type->type); - if (!d) { - /* Same comment from evp_enc.c */ + + if (d == NULL) { EVPerr(EVP_F_EVP_DIGESTINIT_EX, EVP_R_INITIALIZATION_ERROR); ENGINE_finish(impl); return 0; |