diff options
author | teor <teor2345@gmail.com> | 2016-12-03 06:25:46 +1100 |
---|---|---|
committer | teor <teor2345@gmail.com> | 2016-12-03 06:25:46 +1100 |
commit | c100c5c69b4fd3b464b2395263e77cc6e1051ef3 (patch) | |
tree | 3febcbf1f6a8b68c9ab473a1f9120159b6ed2ce1 /src | |
parent | 907cd8a0cfb6da08450902ebb2f21db3cd65e7f7 (diff) | |
download | tor-c100c5c69b4fd3b464b2395263e77cc6e1051ef3.tar.gz tor-c100c5c69b4fd3b464b2395263e77cc6e1051ef3.zip |
Refactor poison_dir allocation and free in test_single_onion_poisoning
This pattern is much less error-prone when future changes are made.
Diffstat (limited to 'src')
-rw-r--r-- | src/test/test_hs.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/test/test_hs.c b/src/test/test_hs.c index f4ba7f9e0e..1039c64fd5 100644 --- a/src/test/test_hs.c +++ b/src/test/test_hs.c @@ -541,6 +541,7 @@ test_single_onion_poisoning(void *arg) rend_service_t *service_2 = tor_malloc_zero(sizeof(rend_service_t)); char *dir2 = tor_strdup(get_fname_rnd("test_hs_dir2")); smartlist_t *services = smartlist_new(); + char *poison_path = NULL; /* No services, no service to verify, no problem! */ mock_options->HiddenServiceSingleHopMode = 0; @@ -706,9 +707,9 @@ test_single_onion_poisoning(void *arg) /* Now remove the poisoning from the first service, and we have the opposite * problem. */ - char *poison_path = rend_service_sos_poison_path(service_1); + poison_path = rend_service_sos_poison_path(service_1); + tt_assert(poison_path); ret = unlink(poison_path); - tor_free(poison_path); tt_assert(ret == 0); /* Unpoisoned service directories with previous keys are ok, as are empty @@ -765,6 +766,7 @@ test_single_onion_poisoning(void *arg) tt_assert(ret == 0); done: + tor_free(poison_path); tor_free(dir1); tor_free(dir2); /* The test harness deletes the directories at exit */ |