Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ticket32994 #1796

Closed
wants to merge 6 commits into from
Closed

Ticket32994 #1796

Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev
config: Simplify port parsing error handling
Part of 32994.
  • Loading branch information
teor2345 committed Mar 14, 2020
commit 3b7b512908e65ad74e672ea846151f31a0b31c97
@@ -6478,6 +6478,8 @@ port_parse_config(smartlist_t *out,
if (! (cfg->entry_cfg.isolation_flags & ISO_SOCKSAUTH))
cfg->entry_cfg.socks_prefer_no_auth = 1;
smartlist_add(out, cfg);
/* out owns cfg now, don't re-use or free it */
cfg = NULL;
} else {
tor_free(cfg);
}
@@ -6500,19 +6502,27 @@ port_parse_config(smartlist_t *out,
log_warn(LD_CONFIG, "You specified a nonzero %sPort along with '%sPort 0' "
"in the same configuration. Did you mean to disable %sPort or "
"not?", portname, portname, portname);
goto err0;
goto err;
}

retval = 0;
err:
if (retval == -1) {
tor_free(cfg);
}
err0:
err:
/* There are two ways we can error out:
* 1. part way through the loop: cfg needs to be freed;
* 2. ending the loop normally: cfg is always NULL.
* In this case, cfg has either been:
* - added to out, then set to NULL, or
* - freed and set to NULL (because out is NULL, or port is 0).
*/
tor_free(cfg);

/* Free the other variables from the loop.
* elts is always non-NULL here, but it may or may not be empty. */
SMARTLIST_FOREACH(elts, char *, cp, tor_free(cp));
smartlist_free(elts);
tor_free(unix_socket_path);
tor_free(addrport);

return retval;
}