From 8812f562a03234723871b893f269db09e78654fc Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 27 Sep 2018 13:05:19 -0400 Subject: Fix a memory leak in --dump-config When freeing a configuration object from confparse.c in dump_config(), we need to call the appropriate higher-level free function (like or_options_free()) and not just config_free(). This only happens with options (since they're the one where options_validate allocates extra stuff) and only when running --dump-config with something other than minimal (since OPTIONS_DUMP_MINIMAL doesn't hit this code). Fixes bug 27893; bugfix on 0.3.2.1-alpha. --- src/app/config/config.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/app/config/config.c') diff --git a/src/app/config/config.c b/src/app/config/config.c index 91e2758650..b8cb50340f 100644 --- a/src/app/config/config.c +++ b/src/app/config/config.c @@ -824,6 +824,7 @@ static void config_maybe_load_geoip_files_(const or_options_t *options, static int options_validate_cb(void *old_options, void *options, void *default_options, int from_setconf, char **msg); +static void options_free_cb(void *options); static void cleanup_protocol_warning_severity_level(void); static void set_protocol_warning_severity_level(int warning_severity); @@ -839,6 +840,7 @@ STATIC config_format_t options_format = { option_deprecation_notes_, option_vars_, options_validate_cb, + options_free_cb, NULL }; @@ -3149,6 +3151,13 @@ options_validate_cb(void *old_options, void *options, void *default_options, return rv; } +/** Callback to free an or_options_t */ +static void +options_free_cb(void *options) +{ + or_options_free_(options); +} + #define REJECT(arg) \ STMT_BEGIN *msg = tor_strdup(arg); return -1; STMT_END #if defined(__GNUC__) && __GNUC__ <= 3 -- cgit v1.2.3-54-g00ecf