File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -747,13 +747,16 @@ int Compilation::performSingleCommand(const Job *Cmd) {
747
747
748
748
for (auto &envPair : Cmd->getExtraEnvironment ()) {
749
749
#if defined(_MSC_VER)
750
- llvm::SmallString<256 > envStr = StringRef (envPair.first );
751
- envStr.append (StringRef (" =" ));
752
- envStr.append (StringRef (envPair.second ));
753
- _putenv (envStr.c_str ());
750
+ int envResult =_putenv_s (envPair.first , envPair.second );
754
751
#else
755
- setenv (envPair.first , envPair.second , /* replacing=*/ true );
752
+ int envResult = setenv (envPair.first , envPair.second , /* replacing=*/ true );
756
753
#endif
754
+ assert (envResult == 0 &&
755
+ " expected environment variable to be set successfully" );
756
+ // Bail out early in release builds.
757
+ if (envResult != 0 ) {
758
+ return envResult;
759
+ }
757
760
}
758
761
759
762
return ExecuteInPlace (ExecPath, argv);
You can’t perform that action at this time.
0 commit comments