diff options
| author | kennytm <kennytm@gmail.com> | 2018-08-14 23:59:05 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-08-14 23:59:05 +0800 |
| commit | 700c5e89f22f4015e601984344c09cc6a3129caf (patch) | |
| tree | 14a7dffeb2fde0f26b79137ff5d0327538e10849 /src/libstd/sys | |
| parent | e401638d0813ed7302e67d4487f1899de1c24ad1 (diff) | |
| parent | c9aca0232064ab3f67eec4ceda3258caa3866129 (diff) | |
| download | rust-700c5e89f22f4015e601984344c09cc6a3129caf.tar.gz rust-700c5e89f22f4015e601984344c09cc6a3129caf.zip | |
Rollup merge of #53208 - BurntPizza:protect-the-environment, r=alexcrichton
Don't panic on std::env::vars() when env is null. Fixes #53200. Reviewer(s): * Do I need to do any `#[cfg()]` here? * Is this use of libc ok for a dev-dependency?
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/unix/os.rs | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index 08c3e154978..f8f0bbd5bc2 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -414,12 +414,8 @@ pub fn env() -> Env { unsafe { let _guard = ENV_LOCK.lock(); let mut environ = *environ(); - if environ == ptr::null() { - panic!("os::env() failure getting env string from OS: {}", - io::Error::last_os_error()); - } let mut result = Vec::new(); - while *environ != ptr::null() { + while environ != ptr::null() && *environ != ptr::null() { if let Some(key_value) = parse(CStr::from_ptr(*environ).to_bytes()) { result.push(key_value); } |
