File tree 2 files changed +30
-5
lines changed
2 files changed +30
-5
lines changed Original file line number Diff line number Diff line change @@ -414,12 +414,8 @@ pub fn env() -> Env {
414
414
unsafe {
415
415
let _guard = ENV_LOCK . lock ( ) ;
416
416
let mut environ = * environ ( ) ;
417
- if environ == ptr:: null ( ) {
418
- panic ! ( "os::env() failure getting env string from OS: {}" ,
419
- io:: Error :: last_os_error( ) ) ;
420
- }
421
417
let mut result = Vec :: new ( ) ;
422
- while * environ != ptr:: null ( ) {
418
+ while environ != ptr :: null ( ) && * environ != ptr:: null ( ) {
423
419
if let Some ( key_value) = parse ( CStr :: from_ptr ( * environ) . to_bytes ( ) ) {
424
420
result. push ( key_value) ;
425
421
}
Original file line number Diff line number Diff line change
1
+ // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ // ignore-windows
12
+ // ignore-wasm32-bare no libc to test ffi with
13
+
14
+ // issue-53200
15
+
16
+ #![ feature( libc) ]
17
+ extern crate libc;
18
+
19
+ use std:: env;
20
+
21
+ // FIXME: more platforms?
22
+ #[ cfg( target_os = "linux" ) ]
23
+ fn main ( ) {
24
+ unsafe { libc:: clearenv ( ) ; }
25
+ assert_eq ! ( env:: vars( ) . count( ) , 0 ) ;
26
+ }
27
+
28
+ #[ cfg( not( target_os = "linux" ) ) ]
29
+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments