Skip to content

Commit

Permalink
add size constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
tautschnig committed Aug 20, 2024
1 parent 41635f0 commit 10493b5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions library/core/src/alloc/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,9 @@ mod verify {

impl kani::Arbitrary for Layout {
fn any() -> Self {
let size = kani::any::<usize>();
unsafe { Layout { size, align: kani::any::<Alignment>() } }
let align = kani::any::<Alignment>();
let size = kani::any_where(|s: &usize| *s <= isize::MAX as usize - (align.as_usize() - 1));
unsafe { Layout { size, align } }
}
}

Expand Down

0 comments on commit 10493b5

Please sign in to comment.