[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Fix memory leaks.
commit 939d12be580c6696638918b9cc04e3210e3e4845
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Tue Sep 22 13:17:17 2020 -0400
Fix memory leaks.
---
src/feature/dirauth/dirvote.c | 4 ++--
src/test/test_dirvote.c | 25 +++++++++++++++++++++++++
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/src/feature/dirauth/dirvote.c b/src/feature/dirauth/dirvote.c
index c1ffa25672..a60112a1c6 100644
--- a/src/feature/dirauth/dirvote.c
+++ b/src/feature/dirauth/dirvote.c
@@ -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, {
diff --git a/src/test/test_dirvote.c b/src/test/test_dirvote.c
index def494959d..447458becf 100644
--- a/src/test/test_dirvote.c
+++ b/src/test/test_dirvote.c
@@ -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);
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits