Skip to content

Commit f1798d3

Browse files
committed
Cast inner type in OsStr::bytes
The innermost type is not [u8] on all platforms but is assumed to have the same memory layout as [u8] since this conversion was done via mem::transmute before.
1 parent cb2a656 commit f1798d3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libstd/ffi/os_str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ impl OsStr {
520520
/// Note: it is *crucial* that this API is private, to avoid
521521
/// revealing the internal, platform-specific encodings.
522522
fn bytes(&self) -> &[u8] {
523-
&self.inner.inner
523+
unsafe { &*(&self.inner as *const _ as *const [u8]) }
524524
}
525525
}
526526

0 commit comments

Comments
 (0)