Skip to content

Commit

Permalink
As of rustc 1.65, Vec/Layout size > isize::MAX is UB
Browse files Browse the repository at this point in the history
More precisely, size when rounded up to the nearest multiple of align.
See rust-lang/rust#95295.
  • Loading branch information
glandium committed Nov 4, 2022
1 parent efc6186 commit 2d44ec6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -824,15 +824,15 @@ mod tests {
fn try_clone_oom() {
let layout = Layout::new::<u8>();
let v =
unsafe { Vec::<u8>::from_raw_parts(alloc(layout), core::usize::MAX, core::usize::MAX) };
unsafe { Vec::<u8>::from_raw_parts(alloc(layout), core::isize::MAX as usize, core::isize::MAX as usize) };
assert!(v.try_clone().is_err());
}

#[test]
fn tryvec_try_clone_oom() {
let layout = Layout::new::<u8>();
let inner =
unsafe { Vec::<u8>::from_raw_parts(alloc(layout), core::usize::MAX, core::usize::MAX) };
unsafe { Vec::<u8>::from_raw_parts(alloc(layout), core::isize::MAX as usize, core::isize::MAX as usize) };
let tv = TryVec { inner };
assert!(tv.try_clone().is_err());
}
Expand Down

0 comments on commit 2d44ec6

Please sign in to comment.