aboutsummaryrefslogtreecommitdiff
path: root/src/app/config/confparse.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-09-27 13:05:19 -0400
committerNick Mathewson <nickm@torproject.org>2018-09-27 13:05:19 -0400
commit8812f562a03234723871b893f269db09e78654fc (patch)
tree1961cbeddd0e702585df9507e14d04d54db530ea /src/app/config/confparse.h
parentde0b07c634c45297bad794567cb44ab91988b0ca (diff)
downloadtor-8812f562a03234723871b893f269db09e78654fc.tar.gz
tor-8812f562a03234723871b893f269db09e78654fc.zip
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.
Diffstat (limited to 'src/app/config/confparse.h')
-rw-r--r--src/app/config/confparse.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/app/config/confparse.h b/src/app/config/confparse.h
index aebd035c56..efaa3e480a 100644
--- a/src/app/config/confparse.h
+++ b/src/app/config/confparse.h
@@ -155,6 +155,9 @@ typedef struct config_var_t {
* of arguments. */
typedef int (*validate_fn_t)(void*,void*,void*,int,char**);
+/** Callback to free a configuration object. */
+typedef void (*free_cfg_fn_t)(void*);
+
/** Information on the keys, value types, key-to-struct-member mappings,
* variable descriptions, validation functions, and abbreviations for a
* configuration or storage format. */
@@ -169,6 +172,7 @@ typedef struct config_format_t {
config_var_t *vars; /**< List of variables we recognize, their default
* values, and where we stick them in the structure. */
validate_fn_t validate_fn; /**< Function to validate config. */
+ free_cfg_fn_t free_fn; /**< Function to free the configuration. */
/** If present, extra is a LINELIST variable for unrecognized
* lines. Otherwise, unrecognized lines are an error. */
config_var_t *extra;