PathBuf incorrectly transmutes OsString to Vec<u8> #124409
Closed
Description
PathBuf contains this gem:
Lines 1172 to 1175 in f56afa0
This effectively transmutes an OsString
to Vec<u8>
. But on Windows, OsString
is Wtf8Buf
:
rust/library/std/src/sys_common/wtf8.rs
Lines 131 to 146 in 51a7396
This is not repr(transparent)
, so there is no guarantee that we can just transmute this. And I think with layout randomization this can actually fail -- that's probably what happened here.
Is there a reason why this uses transmutes rather than some sort of private accessor that exposes a *mut Vec<u8>
through all these layers?