]> git.lizzy.rs Git - rust.git/blobdiff - library/std/src/sys/windows/process.rs
Windows: Fix `Command::env_clear` so it works
[rust.git] / library / std / src / sys / windows / process.rs
index 81dbea4a067399755a1fd029fc3ed514c6c44e05..14de2530842f8da93d16558e109ee6ad50419c8f 100644 (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);