From: tb Date: Fri, 12 Jul 2024 09:25:43 +0000 (+0000) Subject: Clean up X509_EXTENSION_create_by_NID() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=db996e510fa9ca1d20885e30e0b103f3584c6ce9;p=openbsd Clean up X509_EXTENSION_create_by_NID() Remove unnecessary ret parameter and freeing of obj (which looks like a double free or freeing of unallocated memory but actually isn't due to various magic flags). Also make this const correct. ok jsing --- diff --git a/lib/libcrypto/x509/x509_v3.c b/lib/libcrypto/x509/x509_v3.c index b0a30db2e8d..76e9777c259 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.34 2024/07/12 08:58:59 tb Exp $ */ +/* $OpenBSD: x509_v3.c,v 1.35 2024/07/12 09:25:43 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -188,18 +188,14 @@ X509_EXTENSION * X509_EXTENSION_create_by_NID(X509_EXTENSION **ext, int nid, int crit, ASN1_OCTET_STRING *data) { - ASN1_OBJECT *obj; - X509_EXTENSION *ret; + const ASN1_OBJECT *obj; - obj = OBJ_nid2obj(nid); - if (obj == NULL) { + if ((obj = OBJ_nid2obj(nid)) == NULL) { X509error(X509_R_UNKNOWN_NID); return NULL; } - ret = X509_EXTENSION_create_by_OBJ(ext, obj, crit, data); - if (ret == NULL) - ASN1_OBJECT_free(obj); - return ret; + + return X509_EXTENSION_create_by_OBJ(ext, obj, crit, data); } LCRYPTO_ALIAS(X509_EXTENSION_create_by_NID);