Explorar o código

Fix memory leak when options_init_from_string returns error #22605

Daniel Pinto %!s(int64=8) %!d(string=hai) anos
pai
achega
ade9baaf9b
Modificáronse 1 ficheiros con 6 adicións e 0 borrados
  1. 6 0
      src/or/config.c

+ 6 - 0
src/or/config.c

@@ -5210,6 +5210,12 @@ options_init_from_string(const char *cf_defaults, const char *cf,
   return SETOPT_OK;
   return SETOPT_OK;
 
 
  err:
  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(newoptions);
   or_options_free(newdefaultoptions);
   or_options_free(newdefaultoptions);
   if (*msg) {
   if (*msg) {