aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2015-05-28 13:06:30 -0400
committerNick Mathewson <nickm@torproject.org>2015-05-28 13:06:30 -0400
commit3262f3c3f621073d7a5708eff5715fff4abb1cf9 (patch)
tree73b1d27d0675b919b9d80fc9c2772c79dec240de
parent0585d4e94bcced179a52dc459578ddb00dc61344 (diff)
downloadtor-3262f3c3f621073d7a5708eff5715fff4abb1cf9.tar.gz
tor-3262f3c3f621073d7a5708eff5715fff4abb1cf9.zip
Fix leak-on-test-failure in test_routerkeys.c
CID 1301379
-rw-r--r--src/test/test_routerkeys.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/test/test_routerkeys.c b/src/test/test_routerkeys.c
index f0ac9fff71..fbe56860e5 100644
--- a/src/test/test_routerkeys.c
+++ b/src/test/test_routerkeys.c
@@ -86,7 +86,7 @@ test_routerkeys_ed_certs(void *args)
{
(void)args;
ed25519_keypair_t kp1, kp2;
- tor_cert_t *cert[2] = {NULL, NULL};
+ tor_cert_t *cert[2] = {NULL, NULL}, *nocert = NULL;
tor_cert_t *parsed_cert[2] = {NULL, NULL};
time_t now = 1412094534;
uint8_t *junk = NULL;
@@ -156,17 +156,20 @@ test_routerkeys_ed_certs(void *args)
/* Now try some junky certs. */
/* - Truncated */
- tt_ptr_op(NULL, ==,tor_cert_parse(cert[0]->encoded, cert[0]->encoded_len-1));
+ nocert = tor_cert_parse(cert[0]->encoded, cert[0]->encoded_len-1);
+ tt_ptr_op(NULL, ==, nocert);
/* - First byte modified */
cert[0]->encoded[0] = 99;
- tt_ptr_op(NULL, ==,tor_cert_parse(cert[0]->encoded, cert[0]->encoded_len));
+ nocert = tor_cert_parse(cert[0]->encoded, cert[0]->encoded_len);
+ tt_ptr_op(NULL, ==, nocert);
cert[0]->encoded[0] = 1;
/* - Extra byte at the end*/
junk = tor_malloc_zero(cert[0]->encoded_len + 1);
memcpy(junk, cert[0]->encoded, cert[0]->encoded_len);
- tt_ptr_op(NULL, ==, tor_cert_parse(junk, cert[0]->encoded_len+1));
+ nocert = tor_cert_parse(junk, cert[0]->encoded_len+1);
+ tt_ptr_op(NULL, ==, nocert);
/* - Multiple signing key instances */
tor_free(junk);
@@ -179,13 +182,15 @@ test_routerkeys_ed_certs(void *args)
junk[42] = 4; /* exttype */
junk[77] = 32; /* extlen */
junk[78] = 4; /* exttype */
- tt_ptr_op(NULL, ==, tor_cert_parse(junk, 104 + 36 * 2));
+ nocert = tor_cert_parse(junk, 104 + 36 * 2);
+ tt_ptr_op(NULL, ==, nocert);
done:
tor_cert_free(cert[0]);
tor_cert_free(cert[1]);
tor_cert_free(parsed_cert[0]);
tor_cert_free(parsed_cert[1]);
+ tor_cert_free(nocert);
tor_free(junk);
tor_free(base64);
}