Prevent GraphemeStrs created from Strings from leaking (#7920)

This commit is contained in:
Dillard Robertson 2023-08-12 21:13:06 -04:00 committed by GitHub
parent ee3171cc54
commit 01776e6851
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -481,7 +481,7 @@ fn from(g: String) -> Self {
let ptr = Box::into_raw(g.into_bytes().into_boxed_slice()) as *mut u8;
GraphemeStr {
ptr: unsafe { NonNull::new_unchecked(ptr) },
len: i32::try_from(len).unwrap() as u32,
len: (i32::try_from(len).unwrap() as u32) | Self::MASK_OWNED,
phantom: PhantomData,
}
}