Skip to content

Commit 47ffca2

Browse files
authored
Rollup merge of rust-lang#70479 - RalfJung:win-env, r=Mark-Simulacrum
avoid creating unnecessary reference in Windows Env iterator Discovered in rust-lang/miri#1225: the Windows `Env` iterator violates Stacked Borrows by creating an `&u16`, turning it into a raw pointer, and then accessing memory outside the range of that type. There is no need to create a reference here in the first place, so the fix is trivial. Cc @JOE1994 Cc rust-lang/unsafe-code-guidelines#134
2 parents a80ec3b + 2a1e61e commit 47ffca2

File tree

1 file changed

+1
-1
lines changed
  • src/libstd/sys/windows

1 file changed

+1
-1
lines changed

Diff for: src/libstd/sys/windows/os.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl Iterator for Env {
9494
if *self.cur == 0 {
9595
return None;
9696
}
97-
let p = &*self.cur as *const u16;
97+
let p = self.cur as *const u16;
9898
let mut len = 0;
9999
while *p.offset(len) != 0 {
100100
len += 1;

0 commit comments

Comments
 (0)