about summary refs log tree commit diff
path: root/library/std/src/sys
diff options
context:
space:
mode:
authorChris Denton <christophersdenton@gmail.com>2021-06-19 09:46:34 +0100
committerChris Denton <christophersdenton@gmail.com>2021-06-19 09:46:34 +0100
commit365a3586a94dc9ca675ddb02a86e116e8161481a (patch)
tree64ad908eb1920691e4c8e4ca08e78e2d05f0f2ed /library/std/src/sys
parent9839f9c7ff0c550e1234e9784612e981ea0123d5 (diff)
downloadrust-365a3586a94dc9ca675ddb02a86e116e8161481a.tar.gz
rust-365a3586a94dc9ca675ddb02a86e116e8161481a.zip
Windows: Fix `Command::env_clear` so it works
Previously, it would error unless at least one new environment variable was added.
Diffstat (limited to 'library/std/src/sys')
-rw-r--r--library/std/src/sys/windows/process.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/library/std/src/sys/windows/process.rs b/library/std/src/sys/windows/process.rs
index 81dbea4a067..14de2530842 100644
--- a/library/std/src/sys/windows/process.rs
+++ b/library/std/src/sys/windows/process.rs
@@ -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);