From a32b35170819e9b07e0183d19aee21b9a246943b Mon Sep 17 00:00:00 2001 From: tb <> Date: Sat, 14 Apr 2018 07:09:21 +0000 Subject: make ENGINE_finish() succeed on NULL and simplify callers as in OpenSSL commit 7c96dbcdab9 by Rich Salz. This cleans up the caller side quite a bit and reduces the number of lines enclosed in #ifndef OPENSSL_NO_ENGINE. codesearch.debian.net shows that almost nothing checks the return value of ENGINE_finish(). While there, replace a few nearby 'if (!ptr)' with 'if (ptr == NULL)'. ok jsing, tested by & ok inoguchi --- src/lib/libcrypto/evp/pmeth_lib.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/lib/libcrypto/evp/pmeth_lib.c') diff --git a/src/lib/libcrypto/evp/pmeth_lib.c b/src/lib/libcrypto/evp/pmeth_lib.c index fc5f4ef91e..6b86a0ecfb 100644 --- a/src/lib/libcrypto/evp/pmeth_lib.c +++ b/src/lib/libcrypto/evp/pmeth_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmeth_lib.c,v 1.13 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: pmeth_lib.c,v 1.14 2018/04/14 07:09:21 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -188,10 +188,9 @@ int_ctx_new(EVP_PKEY *pkey, ENGINE *e, int id) } ret = malloc(sizeof(EVP_PKEY_CTX)); - if (!ret) { + if (ret == NULL) { #ifndef OPENSSL_NO_ENGINE - if (e) - ENGINE_finish(e); + ENGINE_finish(e); #endif EVPerror(ERR_R_MALLOC_FAILURE); return NULL; @@ -394,10 +393,7 @@ EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx) EVP_PKEY_free(ctx->pkey); EVP_PKEY_free(ctx->peerkey); #ifndef OPENSSL_NO_ENGINE - if (ctx->engine) - /* The EVP_PKEY_CTX we used belongs to an ENGINE, release the - * functional reference we held for this reason. */ - ENGINE_finish(ctx->engine); + ENGINE_finish(ctx->engine); #endif free(ctx); } -- cgit v1.2.3-55-g6feb