Plug memleak
authortb <tb@openbsd.org>
Wed, 29 Dec 2021 23:02:52 +0000 (23:02 +0000)
committertb <tb@openbsd.org>
Wed, 29 Dec 2021 23:02:52 +0000 (23:02 +0000)
CID 345156

regress/lib/libcrypto/x509/constraints.c

index c4dedeb..b552f30 100644 (file)
@@ -331,9 +331,11 @@ test_invalid_domain_constraints(void)
 }
 
 static int
-test_invalid_uri(void) {
+test_invalid_uri(void)
+{
        int j, failure=0;
-       char *hostpart;
+       char *hostpart = NULL;
+
        for (j = 0; invaliduri[j] != NULL; j++) {
                if (x509_constraints_uri_host(invaliduri[j],
                        strlen(invaliduri[j]), &hostpart) != 0) {
@@ -342,7 +344,10 @@ test_invalid_uri(void) {
                        failure = 1;
                        goto done;
                }
+               free(hostpart);
+               hostpart = NULL;
        }
+
  done:
        return failure;
 }