Fix memory leak when options_init_from_string returns error #22605

This commit is contained in:
Daniel Pinto 2017-09-12 23:07:06 +01:00
parent 23147dd168
commit ade9baaf9b

View File

@ -5210,6 +5210,12 @@ options_init_from_string(const char *cf_defaults, const char *cf,
return SETOPT_OK;
err:
if (opened_files) {
SMARTLIST_FOREACH(opened_files, char *, f, tor_free(f));
smartlist_free(opened_files);
}
// may have been set to opened_files, avoid double free
newoptions->FilesOpenedByIncludes = NULL;
or_options_free(newoptions);
or_options_free(newdefaultoptions);
if (*msg) {