File tree 2 files changed +9
-2
lines changed
2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -725,11 +725,11 @@ impl<A: Array> SmallVec<A> {
725
725
let len = self . len ( ) ;
726
726
let start = match range. start_bound ( ) {
727
727
Included ( & n) => n,
728
- Excluded ( & n) => n + 1 ,
728
+ Excluded ( & n) => n. checked_add ( 1 ) . expect ( "Range start out of bounds" ) ,
729
729
Unbounded => 0 ,
730
730
} ;
731
731
let end = match range. end_bound ( ) {
732
- Included ( & n) => n + 1 ,
732
+ Included ( & n) => n. checked_add ( 1 ) . expect ( "Range end out of bounds" ) ,
733
733
Excluded ( & n) => n,
734
734
Unbounded => len,
735
735
} ;
Original file line number Diff line number Diff line change @@ -423,6 +423,13 @@ fn test_invalid_grow() {
423
423
v. grow ( 5 ) ;
424
424
}
425
425
426
+ #[ test]
427
+ #[ should_panic]
428
+ fn drain_overflow ( ) {
429
+ let mut v: SmallVec < [ u8 ; 8 ] > = smallvec ! [ 0 ] ;
430
+ v. drain ( ..=std:: usize:: MAX ) ;
431
+ }
432
+
426
433
#[ test]
427
434
fn test_insert_from_slice ( ) {
428
435
let mut v: SmallVec < [ u8 ; 8 ] > = SmallVec :: new ( ) ;
You can’t perform that action at this time.
0 commit comments