From d5d37122202e65f744a84a6157dee0419fe76ce8 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Fri, 22 Dec 2017 17:38:25 -0800 Subject: [PATCH] Correct some more memory management in env.cpp --- src/env.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/env.cpp b/src/env.cpp index 130877a15..8ef67dc63 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -217,7 +217,7 @@ void var_stack_t::push(bool new_scope) { // Only if we introduce a new shadowing scope; i.e. not if it's just `begin; end` or // "--no-scope-shadowing". if (new_scope && top_node != this->global_env) { - for (auto &var : top_node->env) { + for (const auto &var : top_node->env) { if (var.second.exportv) node->env.insert(var); } } @@ -547,14 +547,14 @@ static void init_path_vars() { /// Initialize the curses subsystem. static void init_curses() { - for (auto var_name : curses_variables) { + for (const auto &var_name : curses_variables) { + std::string name = wcs2string(var_name); const auto var = env_get(var_name, ENV_EXPORT); - const std::string &name = wcs2string(var_name); if (var.missing_or_empty()) { debug(2, L"curses var %s missing or empty", name.c_str()); unsetenv(name.c_str()); } else { - const std::string &value = wcs2string(var->as_string()); + std::string value = wcs2string(var->as_string()); debug(2, L"curses var %s='%s'", name.c_str(), value.c_str()); setenv(name.c_str(), value.c_str(), 1); }