Remove two pointless NULL checks and allocations
authortb <tb@openbsd.org>
Tue, 28 Dec 2021 16:05:23 +0000 (16:05 +0000)
committertb <tb@openbsd.org>
Tue, 28 Dec 2021 16:05:23 +0000 (16:05 +0000)
The ASN.1 template for IPAddressFamily doesn't mark either of its two
members as optional, so they are allocated by IPAddressFamily_new().

ok inoguchi jsing

lib/libcrypto/x509/x509_addr.c

index fda73b3..a0c73bd 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: x509_addr.c,v 1.30 2021/12/28 15:59:13 tb Exp $ */
+/*     $OpenBSD: x509_addr.c,v 1.31 2021/12/28 16:05:23 tb Exp $ */
 /*
  * Contributed to the OpenSSL Project by the American Registry for
  * Internet Numbers ("ARIN").
@@ -787,12 +787,6 @@ make_IPAddressFamily(IPAddrBlocks *addr, const unsigned afi,
 
        if ((f = IPAddressFamily_new()) == NULL)
                goto err;
-       if (f->ipAddressChoice == NULL &&
-           (f->ipAddressChoice = IPAddressChoice_new()) == NULL)
-               goto err;
-       if (f->addressFamily == NULL &&
-           (f->addressFamily = ASN1_OCTET_STRING_new()) == NULL)
-               goto err;
        if (!ASN1_OCTET_STRING_set(f->addressFamily, key, keylen))
                goto err;
        if (!sk_IPAddressFamily_push(addr, f))