File tree 1 file changed +14
-5
lines changed
1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -422,7 +422,9 @@ pub fn setenv<T: BytesContainer>(n: &str, v: T) {
422
422
with_env_lock ( || {
423
423
n. with_c_str ( |nbuf| {
424
424
v. with_c_str ( |vbuf| {
425
- libc:: funcs:: posix01:: unistd:: setenv ( nbuf, vbuf, 1 ) ;
425
+ if libc:: funcs:: posix01:: unistd:: setenv ( nbuf, vbuf, 1 ) != 0 {
426
+ panic ! ( IoError :: last_error( ) ) ;
427
+ }
426
428
} )
427
429
} )
428
430
} )
@@ -438,7 +440,9 @@ pub fn setenv<T: BytesContainer>(n: &str, v: T) {
438
440
439
441
unsafe {
440
442
with_env_lock ( || {
441
- libc:: SetEnvironmentVariableW ( n. as_ptr ( ) , v. as_ptr ( ) ) ;
443
+ if libc:: SetEnvironmentVariableW ( n. as_ptr ( ) , v. as_ptr ( ) ) == 0 {
444
+ panic ! ( IoError :: last_error( ) ) ;
445
+ }
442
446
} )
443
447
}
444
448
}
@@ -453,7 +457,9 @@ pub fn unsetenv(n: &str) {
453
457
unsafe {
454
458
with_env_lock ( || {
455
459
n. with_c_str ( |nbuf| {
456
- libc:: funcs:: posix01:: unistd:: unsetenv ( nbuf) ;
460
+ if libc:: funcs:: posix01:: unistd:: unsetenv ( nbuf) != 0 {
461
+ panic ! ( IoError :: last_error( ) ) ;
462
+ }
457
463
} )
458
464
} )
459
465
}
@@ -465,11 +471,14 @@ pub fn unsetenv(n: &str) {
465
471
n. push ( 0 ) ;
466
472
unsafe {
467
473
with_env_lock ( || {
468
- libc:: SetEnvironmentVariableW ( n. as_ptr ( ) , ptr:: null ( ) ) ;
474
+ if libc:: SetEnvironmentVariableW ( n. as_ptr ( ) , ptr:: null ( ) ) == 0 {
475
+ panic ! ( IoError :: last_error( ) ) ;
476
+ }
469
477
} )
470
478
}
471
479
}
472
- _unsetenv ( n) ;
480
+
481
+ _unsetenv ( n)
473
482
}
474
483
475
484
/// Parses input according to platform conventions for the `PATH`
You can’t perform that action at this time.
0 commit comments