diff options
author | Robert Ransom <rransom.8774@gmail.com> | 2012-02-15 14:09:53 -0800 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-02-17 11:42:21 -0500 |
commit | 33552c16ca3644e2dddd8ba6beee58aabd9d1977 (patch) | |
tree | fa08a6b3dbf508f520902e22dbef62da6ef74746 /src/or/transports.c | |
parent | c0808b795f9b52184a18e7a2960f56ed0e330c4b (diff) | |
download | tor-33552c16ca3644e2dddd8ba6beee58aabd9d1977.tar.gz tor-33552c16ca3644e2dddd8ba6beee58aabd9d1977.zip |
Heap-allocate strings returned by get_current_process_environment_variables
Diffstat (limited to 'src/or/transports.c')
-rw-r--r-- | src/or/transports.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/or/transports.c b/src/or/transports.c index c10490e26c..726419ed87 100644 --- a/src/or/transports.c +++ b/src/or/transports.c @@ -961,13 +961,14 @@ create_managed_proxy_environment(const managed_proxy_t *mp) { const or_options_t *options = get_options(); - /* Environment variables to be added to or set in mp's environment. - * These are heap-allocated and are freed before this function - * returns. */ + /* Environment variables to be added to or set in mp's environment. */ smartlist_t *envs = smartlist_new(); + /* XXXX The next time someone touches this code, shorten the name of + * set_environment_variable_in_smartlist, add a + * set_env_var_in_smartlist_asprintf function, and get rid of the + * silly extra envs smartlist. */ - /* The final environment to be passed to mp. Inherited variables are - * statically allocated; new ones are heap-allocated. */ + /* The final environment to be passed to mp. */ smartlist_t *merged_env_vars = get_current_process_environment_variables(); process_environment_t *env; @@ -1013,16 +1014,17 @@ create_managed_proxy_environment(const managed_proxy_t *mp) } SMARTLIST_FOREACH_BEGIN(envs, const char *, env_var) { - set_environment_variable_in_smartlist(merged_env_vars, env_var, NULL, 0); + set_environment_variable_in_smartlist(merged_env_vars, env_var, + _tor_free, 1); } SMARTLIST_FOREACH_END(env_var); env = process_environment_make(merged_env_vars); - smartlist_free(merged_env_vars); - - SMARTLIST_FOREACH(envs, void *, x, tor_free(x)); smartlist_free(envs); + SMARTLIST_FOREACH(merged_env_vars, void *, x, tor_free(x)); + smartlist_free(merged_env_vars); + return env; } |