Skip to content

Commit b0abe48

Browse files
author
tb
committed
Garbage collect the unused hash and print kp->pubkey_hash instead of NULL.
Make sure kp is freed also on error. ok jsing
1 parent 7d9f5a5 commit b0abe48

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/regress/lib/libtls/keypair/keypairtest.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: keypairtest.c,v 1.4 2018/04/07 16:42:17 jsing Exp $ */
1+
/* $OpenBSD: keypairtest.c,v 1.5 2021/12/04 09:04:36 tb Exp $ */
22
/*
33
* Copyright (c) 2018 Joel Sing <jsing@openbsd.org>
44
*
@@ -89,7 +89,6 @@ do_keypair_tests(void)
8989
X509 *x509_cert = NULL;
9090
struct tls_keypair *kp;
9191
struct tls_error err;
92-
char *hash = NULL;
9392
int failed = 1;
9493

9594
load_file(cert_file, &cert, &cert_len);
@@ -126,7 +125,7 @@ do_keypair_tests(void)
126125
goto done;
127126
if (strcmp(kp->pubkey_hash, PUBKEY_HASH) != 0) {
128127
fprintf(stderr, "FAIL: got pubkey hash '%s', want '%s'",
129-
hash, PUBKEY_HASH);
128+
kp->pubkey_hash, PUBKEY_HASH);
130129
goto done;
131130
}
132131

@@ -161,7 +160,7 @@ do_keypair_tests(void)
161160
goto done;
162161
if (strcmp(kp->pubkey_hash, PUBKEY_HASH) != 0) {
163162
fprintf(stderr, "FAIL: got pubkey hash '%s', want '%s'",
164-
hash, PUBKEY_HASH);
163+
kp->pubkey_hash, PUBKEY_HASH);
165164
goto done;
166165
}
167166

@@ -179,13 +178,11 @@ do_keypair_tests(void)
179178
goto done;
180179
}
181180

182-
tls_keypair_free(kp);
183-
184181
failed = 0;
185182

186183
done:
184+
tls_keypair_free(kp);
187185
X509_free(x509_cert);
188-
free(hash);
189186
free((uint8_t *)cert);
190187
free((uint8_t *)key);
191188
free((uint8_t *)ocsp_staple);

0 commit comments

Comments
 (0)