Commit 939d12be authored by Nick Mathewson's avatar Nick Mathewson 🐻
Browse files

Fix memory leaks.

parent 43672f9f
......@@ -4361,8 +4361,8 @@ get_all_possible_sybil(const smartlist_t *routers)
smartlist_t *routers_ipv6, *routers_ipv4;
routers_ipv6 = smartlist_new();
routers_ipv4 = smartlist_new();
digestmap_t *omit_as_sybil_ipv4 = digestmap_new();
digestmap_t *omit_as_sybil_ipv6 = digestmap_new();
digestmap_t *omit_as_sybil_ipv4;
digestmap_t *omit_as_sybil_ipv6;
digestmap_t *omit_as_sybil = digestmap_new();
// Sort the routers in two lists depending on their IP version
SMARTLIST_FOREACH(routers, routerinfo_t *, ri, {
......
......@@ -357,34 +357,40 @@ test_dirvote_get_sybil_by_ip_version_ipv4(void *arg)
smartlist_add(routers_ipv4, bbbb_ri);
omit_as_sybil = get_sybil_list_by_ip_version(routers_ipv4, AF_INET);
tt_assert(digestmap_isempty(omit_as_sybil) == 1);
digestmap_free(omit_as_sybil, NULL);
CREATE_ROUTER("cccc", cccc, 123, AF_INET);
smartlist_add(routers_ipv4, cccc_ri);
digestmap_set(true_sybil_routers, cccc_digest, cccc_digest);
omit_as_sybil = get_sybil_list_by_ip_version(routers_ipv4, AF_INET);
TEST_SYBIL(true_sybil_routers, omit_as_sybil);
digestmap_free(omit_as_sybil, NULL);
CREATE_ROUTER("dddd", dddd, 123, AF_INET);
smartlist_add(routers_ipv4, dddd_ri);
digestmap_set(true_sybil_routers, dddd_digest, dddd_digest);
omit_as_sybil = get_sybil_list_by_ip_version(routers_ipv4, AF_INET);
TEST_SYBIL(true_sybil_routers, omit_as_sybil);
digestmap_free(omit_as_sybil, NULL);
CREATE_ROUTER("eeee", eeee, 456, AF_INET);
smartlist_add(routers_ipv4, eeee_ri);
omit_as_sybil = get_sybil_list_by_ip_version(routers_ipv4, AF_INET);
TEST_SYBIL(true_sybil_routers, omit_as_sybil);
digestmap_free(omit_as_sybil, NULL);
CREATE_ROUTER("ffff", ffff, 456, AF_INET);
smartlist_add(routers_ipv4, ffff_ri);
omit_as_sybil = get_sybil_list_by_ip_version(routers_ipv4, AF_INET);
TEST_SYBIL(true_sybil_routers, omit_as_sybil);
digestmap_free(omit_as_sybil, NULL);
CREATE_ROUTER("gggg", gggg, 456, AF_INET);
smartlist_add(routers_ipv4, gggg_ri);
digestmap_set(true_sybil_routers, gggg_digest, gggg_digest);
omit_as_sybil = get_sybil_list_by_ip_version(routers_ipv4, AF_INET);
TEST_SYBIL(true_sybil_routers, omit_as_sybil);
digestmap_free(omit_as_sybil, NULL);
CREATE_ROUTER("hhhh", hhhh, 456, AF_INET);
smartlist_add(routers_ipv4, hhhh_ri);
......@@ -433,34 +439,40 @@ test_dirvote_get_sybil_by_ip_version_ipv6(void *arg)
smartlist_add(routers_ipv6, bbbb_ri);
omit_as_sybil = get_sybil_list_by_ip_version(routers_ipv6, AF_INET6);
TEST_SYBIL(true_sybil_routers, omit_as_sybil);
digestmap_free(omit_as_sybil, NULL);
CREATE_ROUTER("cccc", cccc, 123, AF_INET6);
smartlist_add(routers_ipv6, cccc_ri);
digestmap_set(true_sybil_routers, cccc_digest, cccc_digest);
omit_as_sybil = get_sybil_list_by_ip_version(routers_ipv6, AF_INET6);
TEST_SYBIL(true_sybil_routers, omit_as_sybil);
digestmap_free(omit_as_sybil, NULL);
CREATE_ROUTER("dddd", dddd, 123, AF_INET6);
smartlist_add(routers_ipv6, dddd_ri);
digestmap_set(true_sybil_routers, dddd_digest, dddd_digest);
omit_as_sybil = get_sybil_list_by_ip_version(routers_ipv6, AF_INET6);
TEST_SYBIL(true_sybil_routers, omit_as_sybil);
digestmap_free(omit_as_sybil, NULL);
CREATE_ROUTER("eeee", eeee, 456, AF_INET6);
smartlist_add(routers_ipv6, eeee_ri);
omit_as_sybil = get_sybil_list_by_ip_version(routers_ipv6, AF_INET6);
TEST_SYBIL(true_sybil_routers, omit_as_sybil);
digestmap_free(omit_as_sybil, NULL);
CREATE_ROUTER("ffff", ffff, 456, AF_INET6);
smartlist_add(routers_ipv6, ffff_ri);
omit_as_sybil = get_sybil_list_by_ip_version(routers_ipv6, AF_INET6);
TEST_SYBIL(true_sybil_routers, omit_as_sybil);
digestmap_free(omit_as_sybil, NULL);
CREATE_ROUTER("gggg", gggg, 456, AF_INET6);
smartlist_add(routers_ipv6, gggg_ri);
digestmap_set(true_sybil_routers, gggg_digest, gggg_digest);
omit_as_sybil = get_sybil_list_by_ip_version(routers_ipv6, AF_INET6);
TEST_SYBIL(true_sybil_routers, omit_as_sybil);
digestmap_free(omit_as_sybil, NULL);
CREATE_ROUTER("hhhh", hhhh, 456, AF_INET6);
smartlist_add(routers_ipv6, hhhh_ri);
......@@ -508,40 +520,47 @@ test_dirvote_get_all_possible_sybil(void *arg)
smartlist_add(routers, bbbb_ri);
omit_as_sybil = get_all_possible_sybil(routers);
TEST_SYBIL(true_sybil_routers, omit_as_sybil);
digestmap_free(omit_as_sybil, NULL);
CREATE_ROUTER("cccc", cccc, 123, AF_INET);
smartlist_add(routers, cccc_ri);
digestmap_set(true_sybil_routers, cccc_digest, cccc_digest);
omit_as_sybil = get_all_possible_sybil(routers);
TEST_SYBIL(true_sybil_routers, omit_as_sybil);
digestmap_free(omit_as_sybil, NULL);
CREATE_ROUTER("dddd", dddd, 123, AF_INET);
smartlist_add(routers, dddd_ri);
digestmap_set(true_sybil_routers, dddd_digest, dddd_digest);
omit_as_sybil = get_all_possible_sybil(routers);
TEST_SYBIL(true_sybil_routers, omit_as_sybil);
digestmap_free(omit_as_sybil, NULL);
CREATE_ROUTER("eeee", eeee, 456, AF_INET);
smartlist_add(routers, eeee_ri);
omit_as_sybil = get_all_possible_sybil(routers);
TEST_SYBIL(true_sybil_routers, omit_as_sybil);
digestmap_free(omit_as_sybil, NULL);
CREATE_ROUTER("ffff", ffff, 456, AF_INET);
smartlist_add(routers, ffff_ri);
omit_as_sybil = get_all_possible_sybil(routers);
TEST_SYBIL(true_sybil_routers, omit_as_sybil);
digestmap_free(omit_as_sybil, NULL);
CREATE_ROUTER("gggg", gggg, 456, AF_INET);
smartlist_add(routers, gggg_ri);
digestmap_set(true_sybil_routers, gggg_digest, gggg_digest);
omit_as_sybil = get_all_possible_sybil(routers);
TEST_SYBIL(true_sybil_routers, omit_as_sybil);
digestmap_free(omit_as_sybil, NULL);
CREATE_ROUTER("hhhh", hhhh, 456, AF_INET);
smartlist_add(routers, hhhh_ri);
digestmap_set(true_sybil_routers, hhhh_digest, hhhh_digest);
omit_as_sybil = get_all_possible_sybil(routers);
TEST_SYBIL(true_sybil_routers, omit_as_sybil);
digestmap_free(omit_as_sybil, NULL);
CREATE_ROUTER("iiii", iiii, 123, AF_INET6);
smartlist_add(routers, iiii_ri);
......@@ -549,34 +568,40 @@ test_dirvote_get_all_possible_sybil(void *arg)
smartlist_add(routers, jjjj_ri);
omit_as_sybil = get_all_possible_sybil(routers);
TEST_SYBIL(true_sybil_routers, omit_as_sybil);
digestmap_free(omit_as_sybil, NULL);
CREATE_ROUTER("kkkk", kkkk, 123, AF_INET6);
smartlist_add(routers, kkkk_ri);
digestmap_set(true_sybil_routers, kkkk_digest, kkkk_digest);
omit_as_sybil = get_all_possible_sybil(routers);
TEST_SYBIL(true_sybil_routers, omit_as_sybil);
digestmap_free(omit_as_sybil,NULL);
CREATE_ROUTER("llll", llll, 123, AF_INET6);
smartlist_add(routers, llll_ri);
digestmap_set(true_sybil_routers, llll_digest, llll_digest);
omit_as_sybil = get_all_possible_sybil(routers);
TEST_SYBIL(true_sybil_routers, omit_as_sybil);
digestmap_free(omit_as_sybil,NULL);
CREATE_ROUTER("mmmm", mmmm, 456, AF_INET6);
smartlist_add(routers, mmmm_ri);
omit_as_sybil = get_all_possible_sybil(routers);
TEST_SYBIL(true_sybil_routers, omit_as_sybil);
digestmap_free(omit_as_sybil, NULL);
CREATE_ROUTER("nnnn", nnnn, 456, AF_INET6);
smartlist_add(routers, nnnn_ri);
omit_as_sybil = get_all_possible_sybil(routers);
TEST_SYBIL(true_sybil_routers, omit_as_sybil);
digestmap_free(omit_as_sybil, NULL);
CREATE_ROUTER("oooo", oooo, 456, AF_INET6);
smartlist_add(routers, oooo_ri);
digestmap_set(true_sybil_routers, oooo_digest, oooo_digest);
omit_as_sybil = get_all_possible_sybil(routers);
TEST_SYBIL(true_sybil_routers, omit_as_sybil);
digestmap_free(omit_as_sybil, NULL);
CREATE_ROUTER("pppp", pppp, 456, AF_INET6);
smartlist_add(routers, pppp_ri);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment