diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2018-04-14 07:18:38 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2018-04-14 07:18:38 +0000 |
commit | 714d8570c619e443b1d898a740a65887fab962b3 (patch) | |
tree | 2ceb7e2cd50b8659748acec0be2742f0460ddfa4 /regress | |
parent | 364b319f72ecb5c2f1e58716cf073863162c78a8 (diff) |
Make ENGINE_free() succeed on NULL. Matches OpenSSL's behavior and
simplifies the caller side.
tested by & ok inoguchi; discussed with schwarze
Diffstat (limited to 'regress')
-rw-r--r-- | regress/lib/libcrypto/engine/enginetest.c | 17 | ||||
-rw-r--r-- | regress/lib/libcrypto/free/freenull.c | 8 |
2 files changed, 14 insertions, 11 deletions
diff --git a/regress/lib/libcrypto/engine/enginetest.c b/regress/lib/libcrypto/engine/enginetest.c index bb2472a31d6..f39857d6d61 100644 --- a/regress/lib/libcrypto/engine/enginetest.c +++ b/regress/lib/libcrypto/engine/enginetest.c @@ -129,8 +129,7 @@ int main(int argc, char *argv[]) printf("Remove failed!\n"); goto end; } - if (ptr) - ENGINE_free(ptr); + ENGINE_free(ptr); display_engine_list(); if (!ENGINE_add(new_h3) || !ENGINE_add(new_h2)) { printf("Add failed!\n"); @@ -178,8 +177,7 @@ int main(int argc, char *argv[]) if (!ENGINE_remove(ptr)) printf("Remove failed!i - probably no hardware " "support present.\n"); - if (ptr) - ENGINE_free(ptr); + ENGINE_free(ptr); display_engine_list(); if (!ENGINE_add(new_h1) || !ENGINE_remove(new_h1)) { @@ -231,13 +229,12 @@ int main(int argc, char *argv[]) end: if (to_return) ERR_print_errors_fp(stderr); - if (new_h1) ENGINE_free(new_h1); - if (new_h2) ENGINE_free(new_h2); - if (new_h3) ENGINE_free(new_h3); - if (new_h4) ENGINE_free(new_h4); + ENGINE_free(new_h1); + ENGINE_free(new_h2); + ENGINE_free(new_h3); + ENGINE_free(new_h4); for (loop = 0; loop < 512; loop++) - if (block[loop]) - ENGINE_free(block[loop]); + ENGINE_free(block[loop]); ENGINE_cleanup(); CRYPTO_cleanup_all_ex_data(); ERR_free_strings(); diff --git a/regress/lib/libcrypto/free/freenull.c b/regress/lib/libcrypto/free/freenull.c index 5fe6c1a3ed6..89cbd825395 100644 --- a/regress/lib/libcrypto/free/freenull.c +++ b/regress/lib/libcrypto/free/freenull.c @@ -1,4 +1,4 @@ -/* $OpenBSD: freenull.c,v 1.6 2018/02/07 05:07:39 jsing Exp $ */ +/* $OpenBSD: freenull.c,v 1.7 2018/04/14 07:18:37 tb Exp $ */ /* * Copyright (c) 2017 Bob Beck <beck@openbsd.org> * @@ -17,6 +17,9 @@ #include <openssl/asn1.h> #include <openssl/ocsp.h> +#ifndef OPENSSL_NO_ENGINE +#include <openssl/engine.h> +#endif #include <openssl/pkcs12.h> #include <openssl/ts.h> #include <openssl/ui.h> @@ -55,6 +58,9 @@ main(int argc, char **argv) EC_KEY_free(NULL); EC_POINT_clear_free(NULL); EC_POINT_free(NULL); +#ifndef OPENSSL_NO_ENGINE + ENGINE_free(NULL); +#endif EVP_CIPHER_CTX_free(NULL); EVP_PKEY_CTX_free(NULL); EVP_PKEY_free(NULL); |