aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app/config/resolve_addr.c5
-rw-r--r--src/test/test_config.c4
2 files changed, 8 insertions, 1 deletions
diff --git a/src/app/config/resolve_addr.c b/src/app/config/resolve_addr.c
index 8c08c6ec03..808c5ddf0b 100644
--- a/src/app/config/resolve_addr.c
+++ b/src/app/config/resolve_addr.c
@@ -204,6 +204,9 @@ get_address_from_config(const or_options_t *options, int warn_severity,
if (!tor_addr_lookup(cfg->value, family, &addr)) {
tor_addr_copy(addr_out, &addr);
*method_out = "RESOLVED";
+ if (*hostname_out) {
+ tor_free(*hostname_out);
+ }
*hostname_out = tor_strdup(cfg->value);
explicit_ip = false;
num_valid_addr++;
@@ -231,6 +234,7 @@ get_address_from_config(const or_options_t *options, int warn_severity,
log_fn(warn_severity, LD_CONFIG,
"Found %d Address statement of address family %s. "
"Only one is allowed.", num_valid_addr, fmt_af_family(family));
+ tor_free(*hostname_out);
return FN_RET_BAIL;
}
@@ -241,6 +245,7 @@ get_address_from_config(const or_options_t *options, int warn_severity,
* used, custom authorities must be defined else it is a fatal error.
* Furthermore, if the Address was resolved to an internal interface, we
* stop immediately. */
+ tor_free(*hostname_out);
return FN_RET_BAIL;
}
diff --git a/src/test/test_config.c b/src/test/test_config.c
index c4d6a6efcd..045dbde0d8 100644
--- a/src/test/test_config.c
+++ b/src/test/test_config.c
@@ -1334,6 +1334,7 @@ test_config_find_my_address_mixed(void *arg)
retval = find_my_address(options, AF_INET, LOG_NOTICE, &resolved_addr,
&method_used, &hostname_out);
VALIDATE_FOUND_ADDRESS(true, "RESOLVED", "www.torproject.org.v4");
+ tor_free(hostname_out);
/* IPv6 address should be found and considered resolved. */
tor_addr_parse(&test_addr, "0101::0101");
@@ -1382,14 +1383,15 @@ test_config_find_my_address_mixed(void *arg)
retval = find_my_address(options, AF_INET, LOG_NOTICE, &resolved_addr,
&method_used, &hostname_out);
VALIDATE_FOUND_ADDRESS(true, "RESOLVED", "www.torproject.org.v4");
+ tor_free(hostname_out);
/* IPv6 address should be found and considered resolved. */
tor_addr_parse(&test_addr, "0101::0101");
retval = find_my_address(options, AF_INET6, LOG_NOTICE, &resolved_addr,
&method_used, &hostname_out);
VALIDATE_FOUND_ADDRESS(true, "CONFIGURED", NULL);
-
CLEANUP_FOUND_ADDRESS;
+
UNMOCK(tor_addr_lookup);
done: