Skip to content

Commit 0314bb1

Browse files
committed
Basic: guard against nullptr for env
`env` is a default'ed parameter. In some cases it may be passed a `nullptr`, which is not a valid parameter to `llvm::toStringRefArray`. Guard against this case. This allows the swift compiler to work again on Windows!
1 parent aa34eb2 commit 0314bb1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/Basic/Program.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ int swift::ExecuteInPlace(const char *Program, const char **args,
3434

3535
return result;
3636
#else
37-
llvm::ArrayRef<llvm::StringRef> Env = llvm::toStringRefArray(env);
37+
llvm::Optional<llvm::ArrayRef<llvm::StringRef>> Env = llvm::None;
38+
if (env)
39+
Env = llvm::toStringRefArray(env);
3840
int result =
3941
llvm::sys::ExecuteAndWait(Program, llvm::toStringRefArray(args), Env);
4042
if (result >= 0)

0 commit comments

Comments
 (0)