aboutsummaryrefslogtreecommitdiff
path: root/src/app/config/statefile.c
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/statefile.c
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/statefile.c')
-rw-r--r--src/app/config/statefile.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/app/config/statefile.c b/src/app/config/statefile.c
index 510b8964b2..8a8b7ced01 100644
--- a/src/app/config/statefile.c
+++ b/src/app/config/statefile.c
@@ -143,6 +143,8 @@ static int or_state_validate_cb(void *old_options, void *options,
void *default_options,
int from_setconf, char **msg);
+static void or_state_free_cb(void *state);
+
/** Magic value for or_state_t. */
#define OR_STATE_MAGIC 0x57A73f57
@@ -162,6 +164,7 @@ static const config_format_t state_format = {
NULL,
state_vars_,
or_state_validate_cb,
+ or_state_free_cb,
&state_extra_var,
};
@@ -259,6 +262,12 @@ or_state_validate_cb(void *old_state, void *state, void *default_state,
return or_state_validate(state, msg);
}
+static void
+or_state_free_cb(void *state)
+{
+ or_state_free_(state);
+}
+
/** Return 0 if every setting in <b>state</b> is reasonable, and a
* permissible transition from <b>old_state</b>. Else warn and return -1.
* Should have no side effects, except for normalizing the contents of