diff options
author | tb <> | 2021-11-05 17:03:15 +0000 |
---|---|---|
committer | tb <> | 2021-11-05 17:03:15 +0000 |
commit | 9e198f9f65975d087eb88470163c0b3571f17658 (patch) | |
tree | 1c6f2a5954ef2b02772f9c20e187276a6854074c /src/lib | |
parent | be18d241ffee5cafbdfd80a58eb8d0a4b5803511 (diff) | |
download | openbsd-9e198f9f65975d087eb88470163c0b3571f17658.tar.gz openbsd-9e198f9f65975d087eb88470163c0b3571f17658.tar.bz2 openbsd-9e198f9f65975d087eb88470163c0b3571f17658.zip |
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 'src/lib')
-rw-r--r-- | src/lib/libcrypto/x509/x509_lu.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/lib/libcrypto/x509/x509_lu.c b/src/lib/libcrypto/x509/x509_lu.c index 8290f89657..f0a86f0adf 100644 --- a/src/lib/libcrypto/x509/x509_lu.c +++ b/src/lib/libcrypto/x509/x509_lu.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: x509_lu.c,v 1.38 2021/11/05 07:25:36 tb Exp $ */ | 1 | /* $OpenBSD: x509_lu.c,v 1.39 2021/11/05 17:03:15 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -70,22 +70,21 @@ static void X509_OBJECT_dec_ref_count(X509_OBJECT *a); | |||
70 | X509_LOOKUP * | 70 | X509_LOOKUP * |
71 | X509_LOOKUP_new(X509_LOOKUP_METHOD *method) | 71 | X509_LOOKUP_new(X509_LOOKUP_METHOD *method) |
72 | { | 72 | { |
73 | X509_LOOKUP *ret; | 73 | X509_LOOKUP *lu; |
74 | 74 | ||
75 | ret = malloc(sizeof(X509_LOOKUP)); | 75 | if ((lu = calloc(1, sizeof(*lu))) == NULL) { |
76 | if (ret == NULL) | 76 | X509error(ERR_R_MALLOC_FAILURE); |
77 | return NULL; | 77 | return NULL; |
78 | } | ||
78 | 79 | ||
79 | ret->init = 0; | 80 | lu->method = method; |
80 | ret->skip = 0; | 81 | |
81 | ret->method = method; | 82 | if (method->new_item != NULL && !method->new_item(lu)) { |
82 | ret->method_data = NULL; | 83 | free(lu); |
83 | ret->store_ctx = NULL; | ||
84 | if ((method->new_item != NULL) && !method->new_item(ret)) { | ||
85 | free(ret); | ||
86 | return NULL; | 84 | return NULL; |
87 | } | 85 | } |
88 | return ret; | 86 | |
87 | return lu; | ||
89 | } | 88 | } |
90 | 89 | ||
91 | void | 90 | void |