diff options
author | David Goulet <dgoulet@torproject.org> | 2020-07-06 11:21:41 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2020-07-06 11:21:41 -0400 |
commit | 95fc085bf367c1559871b68b3e01f1dc084fab6a (patch) | |
tree | 5c0d48d6b725dcc4a665548ae7e3559102418d68 /src/app | |
parent | ac3bc88343c0cb517eae59660c16f3a6cb273f44 (diff) | |
download | tor-95fc085bf367c1559871b68b3e01f1dc084fab6a.tar.gz tor-95fc085bf367c1559871b68b3e01f1dc084fab6a.zip |
addr: Fix possible memleak in find_my_address()
Unit tests also suffered from a memleak.
Closes #40024
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/app')
-rw-r--r-- | src/app/config/resolve_addr.c | 5 |
1 files changed, 5 insertions, 0 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; } |