diff options
| author | tb <> | 2018-04-14 07:09:21 +0000 |
|---|---|---|
| committer | tb <> | 2018-04-14 07:09:21 +0000 |
| commit | 0c5418014797b1fadca3f270eb2f140fd6f5bdf8 (patch) | |
| tree | 83fef660683163befc47beedefbc0b11b71b2756 /src/lib/libcrypto/evp/pmeth_lib.c | |
| parent | 0c3f32384bbfe8e0484372a52a7b00027b367750 (diff) | |
| download | openbsd-0c5418014797b1fadca3f270eb2f140fd6f5bdf8.tar.gz openbsd-0c5418014797b1fadca3f270eb2f140fd6f5bdf8.tar.bz2 openbsd-0c5418014797b1fadca3f270eb2f140fd6f5bdf8.zip | |
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
Diffstat (limited to 'src/lib/libcrypto/evp/pmeth_lib.c')
| -rw-r--r-- | src/lib/libcrypto/evp/pmeth_lib.c | 12 |
1 files changed, 4 insertions, 8 deletions
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 @@ | |||
| 1 | /* $OpenBSD: pmeth_lib.c,v 1.13 2017/01/29 17:49:23 beck Exp $ */ | 1 | /* $OpenBSD: pmeth_lib.c,v 1.14 2018/04/14 07:09:21 tb Exp $ */ |
| 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2006. | 3 | * project 2006. |
| 4 | */ | 4 | */ |
| @@ -188,10 +188,9 @@ int_ctx_new(EVP_PKEY *pkey, ENGINE *e, int id) | |||
| 188 | } | 188 | } |
| 189 | 189 | ||
| 190 | ret = malloc(sizeof(EVP_PKEY_CTX)); | 190 | ret = malloc(sizeof(EVP_PKEY_CTX)); |
| 191 | if (!ret) { | 191 | if (ret == NULL) { |
| 192 | #ifndef OPENSSL_NO_ENGINE | 192 | #ifndef OPENSSL_NO_ENGINE |
| 193 | if (e) | 193 | ENGINE_finish(e); |
| 194 | ENGINE_finish(e); | ||
| 195 | #endif | 194 | #endif |
| 196 | EVPerror(ERR_R_MALLOC_FAILURE); | 195 | EVPerror(ERR_R_MALLOC_FAILURE); |
| 197 | return NULL; | 196 | return NULL; |
| @@ -394,10 +393,7 @@ EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx) | |||
| 394 | EVP_PKEY_free(ctx->pkey); | 393 | EVP_PKEY_free(ctx->pkey); |
| 395 | EVP_PKEY_free(ctx->peerkey); | 394 | EVP_PKEY_free(ctx->peerkey); |
| 396 | #ifndef OPENSSL_NO_ENGINE | 395 | #ifndef OPENSSL_NO_ENGINE |
| 397 | if (ctx->engine) | 396 | ENGINE_finish(ctx->engine); |
| 398 | /* The EVP_PKEY_CTX we used belongs to an ENGINE, release the | ||
| 399 | * functional reference we held for this reason. */ | ||
| 400 | ENGINE_finish(ctx->engine); | ||
| 401 | #endif | 397 | #endif |
| 402 | free(ctx); | 398 | free(ctx); |
| 403 | } | 399 | } |
