aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_hs_common.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2017-09-11 14:39:24 -0400
committerDavid Goulet <dgoulet@torproject.org>2017-09-11 14:39:24 -0400
commit59072d20277fe6250d0e9b6cf90bf41a75ad651c (patch)
tree9339cf8337e31e9c1931b43edd4aef4cb956e5ff /src/test/test_hs_common.c
parent52c40330c8ab0c43c5773349d033ff7e49f02f53 (diff)
downloadtor-59072d20277fe6250d0e9b6cf90bf41a75ad651c.tar.gz
tor-59072d20277fe6250d0e9b6cf90bf41a75ad651c.zip
test: Fix memleaks
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/test/test_hs_common.c')
-rw-r--r--src/test/test_hs_common.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/test/test_hs_common.c b/src/test/test_hs_common.c
index b0e7f5e1e7..da592eb08f 100644
--- a/src/test/test_hs_common.c
+++ b/src/test/test_hs_common.c
@@ -1494,9 +1494,6 @@ helper_test_hsdir_sync(networkstatus_t *ns,
* the client was also picked by service.
*/
- cleanup_nodelist();
- smartlist_clear(ns->routerstatus_list);
-
/* 1) Initialize service time: consensus and real time */
time_t now = helper_set_consensus_and_system_time(ns,
service_between_srv_and_tp);
@@ -1508,6 +1505,8 @@ helper_test_hsdir_sync(networkstatus_t *ns,
/* Now let's upload our desc to all hsdirs */
upload_descriptor_to_all(service, desc);
+ /* Cleanup right now so we don't memleak on error. */
+ cleanup_nodelist();
/* Check that previous hsdirs were populated */
tt_int_op(smartlist_len(desc->previous_hsdirs), OP_EQ, 6);
@@ -1515,6 +1514,8 @@ helper_test_hsdir_sync(networkstatus_t *ns,
now = helper_set_consensus_and_system_time(ns, client_between_srv_and_tp);
cleanup_nodelist();
+ SMARTLIST_FOREACH(ns->routerstatus_list,
+ routerstatus_t *, rs, routerstatus_free(rs));
smartlist_clear(ns->routerstatus_list);
helper_initialize_big_hash_ring(ns);
@@ -1522,6 +1523,8 @@ helper_test_hsdir_sync(networkstatus_t *ns,
char client_hsdir_b64_digest[BASE64_DIGEST_LEN+1] = {0};
helper_client_pick_hsdir(&service->keys.identity_pk,
client_hsdir_b64_digest);
+ /* Cleanup right now so we don't memleak on error. */
+ cleanup_nodelist();
/* CHECK: Go through the hsdirs chosen by the service and make sure that it
* contains the one picked by the client! */
@@ -1534,6 +1537,9 @@ helper_test_hsdir_sync(networkstatus_t *ns,
* need it for next scenario. */
hs_service_free_all();
hs_service_init();
+ SMARTLIST_FOREACH(ns->routerstatus_list,
+ routerstatus_t *, rs, routerstatus_free(rs));
+ smartlist_clear(ns->routerstatus_list);
}
/** This test ensures that client and service will pick the same HSDirs, under
@@ -1643,9 +1649,6 @@ test_client_service_hsdir_set_sync(void *arg)
helper_test_hsdir_sync(ns, 0, 1, 0);
done:
- SMARTLIST_FOREACH(ns->routerstatus_list,
- routerstatus_t *, rs, routerstatus_free(rs));
- smartlist_clear(ns->routerstatus_list);
networkstatus_vote_free(ns);
nodelist_free_all();
hs_free_all();