summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2020-09-25 11:05:22 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2020-09-25 11:05:22 +0000
commit56af8410bb56a87815014c43b316f1e401524771 (patch)
tree643cf5397a538bd29c28a500e0fbfd4cce48efb6
parentcfc0373b94d357d6a164826dd19ffe9bec93e31e (diff)
Simplify UI_new_method()
Use calloc() instead of malloc() and setting all members manually to 0. Avoid unnecessary else branch.
-rw-r--r--lib/libcrypto/ui/ui_lib.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/lib/libcrypto/ui/ui_lib.c b/lib/libcrypto/ui/ui_lib.c
index 1e3a4ee7051..0a22eba69f2 100644
--- a/lib/libcrypto/ui/ui_lib.c
+++ b/lib/libcrypto/ui/ui_lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ui_lib.c,v 1.41 2020/09/25 10:56:36 tb Exp $ */
+/* $OpenBSD: ui_lib.c,v 1.42 2020/09/25 11:05:21 tb Exp $ */
/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
* project 2001.
*/
@@ -79,20 +79,14 @@ UI_new_method(const UI_METHOD *method)
{
UI *ret;
- ret = malloc(sizeof(UI));
- if (ret == NULL) {
+ if ((ret = calloc(1, sizeof(UI))) == NULL) {
UIerror(ERR_R_MALLOC_FAILURE);
return NULL;
}
- if (method == NULL)
+ if ((ret->meth = method) == NULL)
ret->meth = UI_get_default_method();
- else
- ret->meth = method;
-
- ret->strings = NULL;
- ret->user_data = NULL;
- ret->flags = 0;
CRYPTO_new_ex_data(CRYPTO_EX_INDEX_UI, ret, &ret->ex_data);
+
return ret;
}