Windows: Fix Command::env_clear so it works

Previously, it would error unless at least one new environment variable was added.
This commit is contained in:
Chris Denton 2021-06-19 09:46:34 +01:00
parent 9839f9c7ff
commit 365a3586a9
No known key found for this signature in database
GPG Key ID: 713472F2F45627DE

View File

@ -530,6 +530,12 @@ fn make_envp(maybe_env: Option<BTreeMap<EnvKey, OsString>>) -> io::Result<(*mut
if let Some(env) = maybe_env {
let mut blk = Vec::new();
// If there are no environment variables to set then signal this by
// pushing a null.
if env.is_empty() {
blk.push(0);
}
for (k, v) in env {
blk.extend(ensure_no_nuls(k.0)?.encode_wide());
blk.push('=' as u16);