You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SlotMap::with_capacity_and_key() integer overflow when capacity == usize::MAX #157
Vec::with_capacity(0) succeeds but allocates no space
Violates the “with_capacity” contract
First insertion will trigger reallocation
Impact:
Unexpected behavior when user passes extreme capacity values
Violates API contract
Suggested Fix:
pub fn with_capacity_and_key(capacity: usize) -> Self {
let actual_capacity = capacity.checked_add(1)
.expect(“capacity overflow: requested capacity too large”);
let mut slots = Vec::with_capacity(actual_capacity);
// …
}
Could you please confirm if this is a valid concern?
Activity