[tor-commits] [tor/master] Fix the leaks that valgrind found in the new routerset tests.
nickm at torproject.org
nickm at torproject.org
Wed Sep 3 13:53:48 UTC 2014
commit 0e66edb25437385c50d4054727995d9f6b6be50d
Author: Nick Mathewson <nickm at torproject.org>
Date: Wed Sep 3 09:51:14 2014 -0400
Fix the leaks that valgrind found in the new routerset tests.
(We have a tests-shouldn't-leak policy so that we won't accidentally
ignore true-positives.)
---
src/test/test_routerset.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/src/test/test_routerset.c b/src/test/test_routerset.c
index 0ef2c53..0ea1ef2 100644
--- a/src/test/test_routerset.c
+++ b/src/test/test_routerset.c
@@ -1487,8 +1487,9 @@ NS(test_main)(void *arg)
/* Just recreate list, so we can simply use routerset_free. */
set->list = smartlist_new();
- done:
- routerset_free(set);
+ done:
+ routerset_free(set);
+ smartlist_free(out);
}
#undef NS_SUBMODULE
@@ -1810,8 +1811,8 @@ NS(test_main)(void *arg)
static void
NS(test_main)(void *arg)
{
- const routerset_t *set;
- char *s;
+ routerset_t *set = NULL;
+ char *s = NULL;
(void)arg;
set = NULL;
@@ -1823,12 +1824,14 @@ NS(test_main)(void *arg)
s = routerset_to_string(set);
tt_str_op(s, ==, "");
tor_free(s);
+ routerset_free(set); set = NULL;
set = routerset_new();
smartlist_add(set->list, tor_strndup("a", 1));
s = routerset_to_string(set);
tt_str_op(s, ==, "a");
tor_free(s);
+ routerset_free(set); set = NULL;
set = routerset_new();
smartlist_add(set->list, tor_strndup("a", 1));
@@ -1836,12 +1839,11 @@ NS(test_main)(void *arg)
s = routerset_to_string(set);
tt_str_op(s, ==, "a,b");
tor_free(s);
+ routerset_free(set); set = NULL;
- done:
- if (s)
- tor_free(s);
- if (set)
- routerset_free((routerset_t *)set);
+ done:
+ tor_free(s);
+ routerset_free((routerset_t *)set);
}
#undef NS_SUBMODULE
@@ -2036,24 +2038,22 @@ NS(test_main)(void *arg)
void
NS(smartlist_free)(smartlist_t *s)
{
- (void)s;
CALLED(smartlist_free)++;
+ smartlist_free__real(s);
}
void
NS(strmap_free)(strmap_t *map, void (*free_val)(void*))
{
- (void)map;
- (void)free_val;
CALLED(strmap_free)++;
+ strmap_free__real(map, free_val);
}
void
NS(digestmap_free)(digestmap_t *map, void (*free_val)(void*))
{
- (void)map;
- (void)free_val;
CALLED(digestmap_free)++;
+ digestmap_free__real(map, free_val);
}
#undef NS_SUBMODULE
More information about the tor-commits
mailing list