assign environ to a temp variable to ensure liveness

This commit is contained in:
Jude Taylor 2017-01-06 11:30:14 -08:00 committed by Eelco Dolstra
parent 8079ab87a2
commit c0d55f9183

View file

@ -446,10 +446,13 @@ int main(int argc, char ** argv)
? Strings{"bash", "--rcfile", rcfile} ? Strings{"bash", "--rcfile", rcfile}
: Strings{"bash", rcfile}; : Strings{"bash", rcfile};
environ = stringsToCharPtrs(envStrs).data(); auto envPtrs = stringsToCharPtrs(envStrs);
execvp(getEnv("NIX_BUILD_SHELL", "bash").c_str(), environ = envPtrs.data();
stringsToCharPtrs(args).data());
auto argPtrs = stringsToCharPtrs(args);
execvp(getEnv("NIX_BUILD_SHELL", "bash").c_str(), argPtrs.data());
throw SysError("executing shell"); throw SysError("executing shell");
} }