summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/libcrypto/objects/obj_dat.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/lib/libcrypto/objects/obj_dat.c b/src/lib/libcrypto/objects/obj_dat.c
index 9c4c3179f3..6cfbf8f773 100644
--- a/src/lib/libcrypto/objects/obj_dat.c
+++ b/src/lib/libcrypto/objects/obj_dat.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: obj_dat.c,v 1.60 2023/08/17 09:28:43 tb Exp $ */ 1/* $OpenBSD: obj_dat.c,v 1.61 2023/09/05 14:59:00 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 *
@@ -208,15 +208,6 @@ added_obj_cmp(const ADDED_OBJ *ca, const ADDED_OBJ *cb)
208} 208}
209static IMPLEMENT_LHASH_COMP_FN(added_obj, ADDED_OBJ) 209static IMPLEMENT_LHASH_COMP_FN(added_obj, ADDED_OBJ)
210 210
211static int
212init_added(void)
213{
214 if (added != NULL)
215 return (1);
216 added = lh_ADDED_OBJ_new();
217 return (added != NULL);
218}
219
220static void 211static void
221cleanup1_doall(ADDED_OBJ *a) 212cleanup1_doall(ADDED_OBJ *a)
222{ 213{
@@ -289,13 +280,16 @@ LCRYPTO_ALIAS(OBJ_new_nid);
289int 280int
290OBJ_add_object(const ASN1_OBJECT *obj) 281OBJ_add_object(const ASN1_OBJECT *obj)
291{ 282{
292 ASN1_OBJECT *o; 283 ASN1_OBJECT *o = NULL;
293 ADDED_OBJ *ao[4] = {NULL, NULL, NULL, NULL}, *aop; 284 ADDED_OBJ *ao[4] = {NULL, NULL, NULL, NULL}, *aop;
294 int i; 285 int i;
295 286
296 if (added == NULL) 287 if (added == NULL)
297 if (!init_added()) 288 added = lh_ADDED_OBJ_new();
298 return (0); 289 if (added == NULL)
290 goto err;
291 if (obj == NULL || obj->nid == NID_undef)
292 goto err;
299 if ((o = OBJ_dup(obj)) == NULL) 293 if ((o = OBJ_dup(obj)) == NULL)
300 goto err; 294 goto err;
301 if (!(ao[ADDED_NID] = malloc(sizeof(ADDED_OBJ)))) 295 if (!(ao[ADDED_NID] = malloc(sizeof(ADDED_OBJ))))