-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows: Fix Command::env_clear
so it works if no variables are set
#86467
Conversation
Previously, it would error unless at least one new environment variable was added.
r? @m-ou-se (rust-highfive has picked a reviewer for you, use r? to override) |
Looks reasonable to me, could you add a test to https://github.com/rust-lang/rust/blob/master/library/std/src/process/tests.rs? |
Ok, I've added a test and confirmed it fails without this patch and succeeds with it. |
LGTM and confirmed that it worked well on my local, thanks! r? @JohnTitor @bors r+ |
📌 Commit 16145a9 has been approved by |
☀️ Test successful - checks-actions |
Previously, it would error unless at least one new environment variable was added. The missing null presumably meant that Windows was reading random memory in that case.
See: CreateProcessW (scroll down to
lpEnvironment
). Essentially the environment block is a null terminated list of null terminated strings and an empty list is\0\0
and not\0
.EDIT: Oh, CreateEnvironmentBlock states this much more explicitly.
Fixes #31259