summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2021-11-05 17:03:16 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2021-11-05 17:03:16 +0000
commite7c4d5d479757194cf38bc4faa1eca802344a3fc (patch)
tree8f676f30e033650f072b92c1384ae4a5c09744a3 /lib
parentde5bde5cca9c9295d61f6f3c192ed974d780b38d (diff)
Cleanup X509_LOOKUP_new()
Switch from malloc() to calloc() and drop a bunch of initializations to 0. Call the returned object lu instead of the generic ret. ok jsing
Diffstat (limited to 'lib')
-rw-r--r--lib/libcrypto/x509/x509_lu.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/lib/libcrypto/x509/x509_lu.c b/lib/libcrypto/x509/x509_lu.c
index 8290f896577..f0a86f0adf6 100644
--- a/lib/libcrypto/x509/x509_lu.c
+++ b/lib/libcrypto/x509/x509_lu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: x509_lu.c,v 1.38 2021/11/05 07:25:36 tb Exp $ */
+/* $OpenBSD: x509_lu.c,v 1.39 2021/11/05 17:03:15 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -70,22 +70,21 @@ static void X509_OBJECT_dec_ref_count(X509_OBJECT *a);
X509_LOOKUP *
X509_LOOKUP_new(X509_LOOKUP_METHOD *method)
{
- X509_LOOKUP *ret;
+ X509_LOOKUP *lu;
- ret = malloc(sizeof(X509_LOOKUP));
- if (ret == NULL)
+ if ((lu = calloc(1, sizeof(*lu))) == NULL) {
+ X509error(ERR_R_MALLOC_FAILURE);
return NULL;
+ }
- ret->init = 0;
- ret->skip = 0;
- ret->method = method;
- ret->method_data = NULL;
- ret->store_ctx = NULL;
- if ((method->new_item != NULL) && !method->new_item(ret)) {
- free(ret);
+ lu->method = method;
+
+ if (method->new_item != NULL && !method->new_item(lu)) {
+ free(lu);
return NULL;
}
- return ret;
+
+ return lu;
}
void