]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix memory leak when options_init_from_string returns error #22605
authorDaniel Pinto <danielpinto52@gmail.com>
Tue, 12 Sep 2017 22:07:06 +0000 (23:07 +0100)
committerDaniel Pinto <danielpinto52@gmail.com>
Tue, 12 Sep 2017 22:07:06 +0000 (23:07 +0100)
src/or/config.c

index 56d2e0621a404685cacabf90a96943c3e6e740f8..753547767fefcd413ea9a2da850a3903fff642e6 100644 (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) {