summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2024-07-12 09:31:29 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2024-07-12 09:31:29 +0000
commitf53295de91cc9ab53ff0808f15db4042f9153e87 (patch)
tree25a905d2fb17efb6ee3f5b4e8430bddccb729907
parent3b252b3424b3ab1fbfd93d41211614ec35c15bf5 (diff)
Streamline X509_EXTENSION_create_by_OBJ()
ok jsing
-rw-r--r--lib/libcrypto/x509/x509_v3.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/libcrypto/x509/x509_v3.c b/lib/libcrypto/x509/x509_v3.c
index 76e9777c259..99d26f39fb7 100644
--- a/lib/libcrypto/x509/x509_v3.c
+++ b/lib/libcrypto/x509/x509_v3.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: x509_v3.c,v 1.35 2024/07/12 09:25:43 tb Exp $ */
+/* $OpenBSD: x509_v3.c,v 1.36 2024/07/12 09:31:28 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -205,13 +205,12 @@ X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ext, const ASN1_OBJECT *obj,
{
X509_EXTENSION *ret;
- if (ext == NULL || *ext == NULL) {
- if ((ret = X509_EXTENSION_new()) == NULL) {
- X509error(ERR_R_MALLOC_FAILURE);
- return NULL;
- }
- } else
- ret= *ext;
+ if (ext == NULL || (ret = *ext) == NULL)
+ ret = X509_EXTENSION_new();
+ if (ret == NULL) {
+ X509error(ERR_R_MALLOC_FAILURE);
+ goto err;
+ }
if (!X509_EXTENSION_set_object(ret, obj))
goto err;
@@ -220,13 +219,15 @@ X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ext, const ASN1_OBJECT *obj,
if (!X509_EXTENSION_set_data(ret, data))
goto err;
- if (ext != NULL && *ext == NULL)
+ if (ext != NULL)
*ext = ret;
+
return ret;
err:
if (ext == NULL || ret != *ext)
X509_EXTENSION_free(ret);
+
return NULL;
}
LCRYPTO_ALIAS(X509_EXTENSION_create_by_OBJ);