summaryrefslogtreecommitdiffstats
path: root/lib/libcrypto/ui/ui_lib.c
diff options
context:
space:
mode:
authortb <tb@openbsd.org>2020-09-25 11:05:21 +0000
committertb <tb@openbsd.org>2020-09-25 11:05:21 +0000
commitc4393b6d2d075231edd76cce9e8a39fe7132724c (patch)
tree48ccdc5421528a7fdad562955bdf60e382b703e6 /lib/libcrypto/ui/ui_lib.c
parentMove variable declaration to the top of UI_set_result and ditch (diff)
downloadwireguard-openbsd-c4393b6d2d075231edd76cce9e8a39fe7132724c.tar.xz
wireguard-openbsd-c4393b6d2d075231edd76cce9e8a39fe7132724c.zip
Simplify UI_new_method()
Use calloc() instead of malloc() and setting all members manually to 0. Avoid unnecessary else branch.
Diffstat (limited to 'lib/libcrypto/ui/ui_lib.c')
-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;
}