Skip to content

Commit 7850d99

Browse files
Fix UB in From<String> for BoxedString
bodil#34
1 parent e407ca2 commit 7850d99

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/boxed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ impl From<String> for BoxedString {
178178
let len = s.len();
179179
let cap = s.capacity();
180180
#[allow(unsafe_code)]
181-
let ptr = unsafe { NonNull::new_unchecked(s.as_mut_ptr()) };
181+
let ptr = unsafe { NonNull::new_unchecked(s.as_mut_vec().as_mut_ptr()) };
182182
let old_layout = Layout::array::<u8>(cap).unwrap();
183183

184184
use alloc::alloc::Allocator;

0 commit comments

Comments
 (0)