Fix the log-severities memory-leak in tor-resolve.c

Also, rename the variable to have a more manageable name, and make
its scope more clear.

Fixes bug 24582; bugfix on 0.2.1.1-alpha.
This commit is contained in:
Nick Mathewson 2017-12-11 11:49:57 -05:00
parent ea929e8456
commit e18840f619
2 changed files with 10 additions and 4 deletions

4
changes/bug24582 Normal file
View File

@ -0,0 +1,4 @@
o Minor bugfixes (debugging, memory leaks):
- Fix a harmless memory leak in tor-resolve. Fixes bug 24582;
bugfix on 0.2.1.1-alpha.

View File

@ -347,7 +347,6 @@ main(int argc, char **argv)
int n_args; int n_args;
tor_addr_t result; tor_addr_t result;
char *result_hostname = NULL; char *result_hostname = NULL;
log_severity_list_t *s = tor_malloc_zero(sizeof(log_severity_list_t));
init_logging(1); init_logging(1);
sandbox_disable_getaddrinfo_cache(); sandbox_disable_getaddrinfo_cache();
@ -398,11 +397,14 @@ main(int argc, char **argv)
usage(); usage();
} }
log_severity_list_t *severities =
tor_malloc_zero(sizeof(log_severity_list_t));
if (isVerbose) if (isVerbose)
set_log_severity_config(LOG_DEBUG, LOG_ERR, s); set_log_severity_config(LOG_DEBUG, LOG_ERR, severities);
else else
set_log_severity_config(LOG_WARN, LOG_ERR, s); set_log_severity_config(LOG_WARN, LOG_ERR, severities);
add_stream_log(s, "<stderr>", fileno(stderr)); add_stream_log(severities, "<stderr>", fileno(stderr));
tor_free(severities);
if (n_args == 1) { if (n_args == 1) {
log_debug(LD_CONFIG, "defaulting to localhost"); log_debug(LD_CONFIG, "defaulting to localhost");