diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-12-29 09:33:36 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-12-29 10:00:22 -0500 |
commit | 3538dfc91fa34c1cf4e34a334c76de65883bbc0e (patch) | |
tree | c6b1a8e977a954b8a7b0be9dd3a18cb82c862d35 /src/test/test_config.c | |
parent | c07747be2e5bd4b9311c260b49f4007975138005 (diff) | |
download | tor-3538dfc91fa34c1cf4e34a334c76de65883bbc0e.tar.gz tor-3538dfc91fa34c1cf4e34a334c76de65883bbc0e.zip |
Fix memory leaks in resolvemyaddr tests
Diffstat (limited to 'src/test/test_config.c')
-rw-r--r-- | src/test/test_config.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/test/test_config.c b/src/test/test_config.c index 4217720174..b9a0672aba 100644 --- a/src/test/test_config.c +++ b/src/test/test_config.c @@ -781,7 +781,7 @@ test_config_resolve_my_address(void *arg) or_options_t *options; uint32_t resolved_addr; const char *method_used; - char *hostname_out; + char *hostname_out = NULL; int retval; int prev_n_hostname_01010101; int prev_n_hostname_localhost; @@ -844,6 +844,7 @@ test_config_resolve_my_address(void *arg) UNMOCK(tor_lookup_hostname); tor_free(options->Address); + tor_free(hostname_out); /* * CASE 3: @@ -875,6 +876,8 @@ test_config_resolve_my_address(void *arg) UNMOCK(tor_gethostname); UNMOCK(tor_lookup_hostname); + tor_free(hostname_out); + /* * CASE 4: * Given that options->Address is a local host address, we want @@ -892,6 +895,7 @@ test_config_resolve_my_address(void *arg) tt_assert(retval == -1); tor_free(options->Address); + tor_free(hostname_out); /* * CASE 5: @@ -915,7 +919,7 @@ test_config_resolve_my_address(void *arg) UNMOCK(tor_lookup_hostname); tor_free(options->Address); - options->Address = NULL; + tor_free(hostname_out); /* * CASE 6: @@ -934,6 +938,8 @@ test_config_resolve_my_address(void *arg) tt_assert(retval == -1); UNMOCK(tor_gethostname); + tor_free(hostname_out); + /* * CASE 7: @@ -959,6 +965,7 @@ test_config_resolve_my_address(void *arg) tt_assert(resolved_addr == ntohl(0x08080808)); UNMOCK(get_interface_address); + tor_free(hostname_out); /* * CASE 8: @@ -982,6 +989,7 @@ test_config_resolve_my_address(void *arg) tt_assert(retval == -1); UNMOCK(get_interface_address); + tor_free(hostname_out); /* * CASE 9: @@ -1015,6 +1023,8 @@ test_config_resolve_my_address(void *arg) UNMOCK(tor_gethostname); UNMOCK(get_interface_address6); + tor_free(hostname_out); + /* * CASE 10: We want resolve_my_address() to fail if all of the following * are true: @@ -1041,6 +1051,8 @@ test_config_resolve_my_address(void *arg) UNMOCK(tor_gethostname); UNMOCK(tor_lookup_hostname); + tor_free(hostname_out); + /* * CASE 11: * Suppose the following sequence of events: @@ -1138,10 +1150,11 @@ test_config_resolve_my_address(void *arg) UNMOCK(tor_gethostname); - done: + done: tor_free(options->Address); tor_free(options->DirAuthorities); or_options_free(options); + tor_free(hostname_out); UNMOCK(tor_gethostname); UNMOCK(tor_lookup_hostname); |