about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJude Taylor <me@jude.bio>2017-01-06T19·30-0800
committerEelco Dolstra <edolstra@gmail.com>2017-01-16T22·52+0100
commitc0d55f918379f46b87e43457745895439a85555c (patch)
tree4e3c4d951ddc4dc8f613f8e106cd69ee817c7e73 /src
parent8079ab87a2a7cd288a35334517da7a808af8e1e0 (diff)
assign environ to a temp variable to ensure liveness
Diffstat (limited to 'src')
-rwxr-xr-xsrc/nix-build/nix-build.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/nix-build/nix-build.cc b/src/nix-build/nix-build.cc
index 2bb12c9b27..3eb2d2c0b7 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");
             }