File tree 2 files changed +4
-0
lines changed
2 files changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -534,6 +534,8 @@ impl OsStr {
534
534
fn from_inner_mut ( inner : & mut Slice ) -> & mut OsStr {
535
535
// Safety: OsStr is just a wrapper of Slice,
536
536
// therefore converting &mut Slice to &mut OsStr is safe.
537
+ // Any method that mutates OsStr must be careful not to
538
+ // break platform-specific encoding, in particular Wtf8 on Windows.
537
539
unsafe { & mut * ( inner as * mut Slice as * mut OsStr ) }
538
540
}
539
541
Original file line number Diff line number Diff line change @@ -87,6 +87,8 @@ impl Buf {
87
87
// Safety: Slice is just a wrapper for Wtf8,
88
88
// and self.inner.as_mut_slice() returns &mut Wtf8.
89
89
// Therefore, transmuting &mut Wtf8 to &mut Slice is safe.
90
+ // Additionally, care should be taken to ensure the slice
91
+ // is always valid Wtf8.
90
92
unsafe { mem:: transmute ( self . inner . as_mut_slice ( ) ) }
91
93
}
92
94
You can’t perform that action at this time.
0 commit comments