diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-12-22 12:27:26 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-12-22 12:27:26 -0500 |
commit | 03d2df62f614f97d2b5cf52518565ce91333ba87 (patch) | |
tree | 0d9ae7750a5bfd29c886a3820306fdec97fbae78 /src/test/test_dir.c | |
parent | b94cb401d2185566e7fb52b78c5a5a6747987f99 (diff) | |
download | tor-03d2df62f614f97d2b5cf52518565ce91333ba87.tar.gz tor-03d2df62f614f97d2b5cf52518565ce91333ba87.zip |
Fix a bunch of memory leaks in the unit tests. Found with valgrind
Diffstat (limited to 'src/test/test_dir.c')
-rw-r--r-- | src/test/test_dir.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/test/test_dir.c b/src/test/test_dir.c index 2659fbcfb8..4cd8aa8759 100644 --- a/src/test/test_dir.c +++ b/src/test/test_dir.c @@ -388,6 +388,12 @@ test_dir_routerparse_bad(void *arg) #include "example_extrainfo.inc" static void +routerinfo_free_wrapper_(void *arg) +{ + routerinfo_free(arg); +} + +static void test_dir_extrainfo_parsing(void *arg) { (void) arg; @@ -455,9 +461,9 @@ test_dir_extrainfo_parsing(void *arg) #undef CHECK_FAIL done: + extrainfo_free(ei); routerinfo_free(ri); - /* XXXX elements should get freed too */ - digestmap_free((digestmap_t*)map, NULL); + digestmap_free((digestmap_t*)map, routerinfo_free_wrapper_); } static void @@ -552,9 +558,8 @@ test_dir_parse_router_list(void *arg) SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp)); smartlist_free(chunks); routerinfo_free(ri); - /* XXXX this leaks: */ if (map) { - digestmap_free((digestmap_t*)map, NULL); + digestmap_free((digestmap_t*)map, routerinfo_free_wrapper_); router_get_routerlist()->identity_map = (struct digest_ri_map_t*)digestmap_new(); } |