From 0a9c17a61ad7193a051c53ea2a0cb91e012f014e Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 17 Apr 2013 11:34:15 -0400 Subject: Fix memory leak when sending configuration-changed event Fix for bug #8718; bugfix on 0.2.3.3-alpha. --- src/or/config.c | 3 ++- src/or/control.c | 2 +- src/or/control.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src/or') diff --git a/src/or/config.c b/src/or/config.c index 16eadf917b..236955b2bf 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -785,12 +785,13 @@ set_options(or_options_t *new_val, char **msg) tor_free(line); } } else { - smartlist_add(elements, (char*)options_format.vars[i].name); + smartlist_add(elements, tor_strdup(options_format.vars[i].name)); smartlist_add(elements, NULL); } } } control_event_conf_changed(elements); + SMARTLIST_FOREACH(elements, char *, cp, tor_free(cp)); smartlist_free(elements); } diff --git a/src/or/control.c b/src/or/control.c index fc7bae23e1..417f6c6db2 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -4347,7 +4347,7 @@ control_event_guard(const char *nickname, const char *digest, * a smartlist_t containing (key, value, ...) pairs in sequence. * value can be NULL. */ int -control_event_conf_changed(smartlist_t *elements) +control_event_conf_changed(const smartlist_t *elements) { int i; char *result; diff --git a/src/or/control.h b/src/or/control.h index f301ce91be..943d67eeaf 100644 --- a/src/or/control.h +++ b/src/or/control.h @@ -71,7 +71,7 @@ int control_event_server_status(int severity, const char *format, ...) CHECK_PRINTF(2,3); int control_event_guard(const char *nickname, const char *digest, const char *status); -int control_event_conf_changed(smartlist_t *elements); +int control_event_conf_changed(const smartlist_t *elements); int control_event_buildtimeout_set(const circuit_build_times_t *cbt, buildtimeout_set_event_t type); int control_event_signal(uintptr_t signal); -- cgit v1.2.3-54-g00ecf