summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/libcrypto/x509/x509_v3.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/lib/libcrypto/x509/x509_v3.c b/src/lib/libcrypto/x509/x509_v3.c
index 76e9777c25..99d26f39fb 100644
--- a/src/lib/libcrypto/x509/x509_v3.c
+++ b/src/lib/libcrypto/x509/x509_v3.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_v3.c,v 1.35 2024/07/12 09:25:43 tb Exp $ */ 1/* $OpenBSD: x509_v3.c,v 1.36 2024/07/12 09:31:28 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 *
@@ -205,13 +205,12 @@ X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ext, const ASN1_OBJECT *obj,
205{ 205{
206 X509_EXTENSION *ret; 206 X509_EXTENSION *ret;
207 207
208 if (ext == NULL || *ext == NULL) { 208 if (ext == NULL || (ret = *ext) == NULL)
209 if ((ret = X509_EXTENSION_new()) == NULL) { 209 ret = X509_EXTENSION_new();
210 X509error(ERR_R_MALLOC_FAILURE); 210 if (ret == NULL) {
211 return NULL; 211 X509error(ERR_R_MALLOC_FAILURE);
212 } 212 goto err;
213 } else 213 }
214 ret= *ext;
215 214
216 if (!X509_EXTENSION_set_object(ret, obj)) 215 if (!X509_EXTENSION_set_object(ret, obj))
217 goto err; 216 goto err;
@@ -220,13 +219,15 @@ X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ext, const ASN1_OBJECT *obj,
220 if (!X509_EXTENSION_set_data(ret, data)) 219 if (!X509_EXTENSION_set_data(ret, data))
221 goto err; 220 goto err;
222 221
223 if (ext != NULL && *ext == NULL) 222 if (ext != NULL)
224 *ext = ret; 223 *ext = ret;
224
225 return ret; 225 return ret;
226 226
227 err: 227 err:
228 if (ext == NULL || ret != *ext) 228 if (ext == NULL || ret != *ext)
229 X509_EXTENSION_free(ret); 229 X509_EXTENSION_free(ret);
230
230 return NULL; 231 return NULL;
231} 232}
232LCRYPTO_ALIAS(X509_EXTENSION_create_by_OBJ); 233LCRYPTO_ALIAS(X509_EXTENSION_create_by_OBJ);