From c0d55f918379f46b87e43457745895439a85555c Mon Sep 17 00:00:00 2001 From: Jude Taylor Date: Fri, 6 Jan 2017 11:30:14 -0800 Subject: [PATCH] assign environ to a temp variable to ensure liveness --- src/nix-build/nix-build.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/nix-build/nix-build.cc b/src/nix-build/nix-build.cc index 2bb12c9b2..3eb2d2c0b 100755 --- a/src/nix-build/nix-build.cc +++ b/src/nix-build/nix-build.cc @@ -446,10 +446,13 @@ int main(int argc, char ** argv) ? Strings{"bash", "--rcfile", rcfile} : Strings{"bash", rcfile}; - environ = stringsToCharPtrs(envStrs).data(); + auto envPtrs = stringsToCharPtrs(envStrs); - execvp(getEnv("NIX_BUILD_SHELL", "bash").c_str(), - stringsToCharPtrs(args).data()); + environ = envPtrs.data(); + + auto argPtrs = stringsToCharPtrs(args); + + execvp(getEnv("NIX_BUILD_SHELL", "bash").c_str(), argPtrs.data()); throw SysError("executing shell"); }