aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-11-20 09:14:08 -0500
committerNick Mathewson <nickm@torproject.org>2019-11-20 09:14:08 -0500
commitcf7580ab069ff5bd60648e7384aefda8a2e344b7 (patch)
tree6dd5691437c0b26e0b79ba64be122cc760745f79 /src/app
parent21b3303657f724e7ce4362483092680368839058 (diff)
downloadtor-cf7580ab069ff5bd60648e7384aefda8a2e344b7.tar.gz
tor-cf7580ab069ff5bd60648e7384aefda8a2e344b7.zip
Free options objects for which validation fails.
Also free options objects when we discard them due to TestingTorOptions. Fixes bug 32555; bug not in any released Tor.
Diffstat (limited to 'src/app')
-rw-r--r--src/app/config/config.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/app/config/config.c b/src/app/config/config.c
index 06607e3807..ad41c709d0 100644
--- a/src/app/config/config.c
+++ b/src/app/config/config.c
@@ -4590,6 +4590,7 @@ options_init_from_string(const char *cf_defaults, const char *cf,
newoptions->IncludeUsed = cf_has_include;
newoptions->FilesOpenedByIncludes = opened_files;
+ opened_files = NULL; // prevent double-free.
/* If this is a testing network configuration, change defaults
* for a list of dependent config options, and try this function again. */
@@ -4600,13 +4601,11 @@ options_init_from_string(const char *cf_defaults, const char *cf,
goto err;
}
- newoptions->IncludeUsed = cf_has_include;
- newoptions->FilesOpenedByIncludes = opened_files;
- opened_files = NULL; // prevent double-free.
-
err = options_validate_and_set(oldoptions, newoptions, msg);
- if (err < 0)
+ if (err < 0) {
+ newoptions = NULL; // This was already freed in options_validate_and_set.
goto err;
+ }
or_options_free(global_default_options);
global_default_options = newdefaultoptions;
@@ -4620,6 +4619,7 @@ options_init_from_string(const char *cf_defaults, const char *cf,
smartlist_free(opened_files);
}
or_options_free(newdefaultoptions);
+ or_options_free(newoptions);
if (*msg) {
char *old_msg = *msg;
tor_asprintf(msg, "Failed to parse/validate config: %s", old_msg);