-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Closed
Description
This gives undefined behaviour due to overflow:
fn main() {
let one_iter = Some(0).into_iter();
let big_iter = std::iter::repeat(0).take(usize::max_value());
one_iter.chain(big_iter).collect::<Vec<_>>();
}
The problem is the overflow on the addition here:
rust/src/libcollections/vec.rs
Lines 1485 to 1489 in a643092
| let mut vector = Vec::with_capacity(1 + lower); | |
| unsafe { | |
| ptr::write(vector.get_unchecked_mut(0), element); | |
| vector.set_len(1); | |
| } |
Metadata
Metadata
Assignees
Labels
No labels