SliceVec fuzzer + overflow fix on usize::MAX ranges (#99)

* add slicevec fuzzer

* prevent overflow on range calculation
This commit is contained in:
Soveu
2020-08-09 18:45:19 +02:00
committed by GitHub
parent 1196d2ae7c
commit 52b17b84cd
5 changed files with 131 additions and 8 deletions
+2 -2
View File
@@ -754,11 +754,11 @@ impl<A: Array> ArrayVec<A> {
use core::ops::Bound;
let start = match range.start_bound() {
Bound::Included(x) => *x,
Bound::Excluded(x) => x + 1,
Bound::Excluded(x) => x.saturating_add(1),
Bound::Unbounded => 0,
};
let end = match range.end_bound() {
Bound::Included(x) => x + 1,
Bound::Included(x) => x.saturating_add(1),
Bound::Excluded(x) => *x,
Bound::Unbounded => self.len(),
};
+2 -2
View File
@@ -21,11 +21,11 @@ impl<'a, T: 'a + Default> ArrayVecDrain<'a, T> {
let start = match range.start_bound() {
Bound::Unbounded => 0,
Bound::Included(&n) => n,
Bound::Excluded(&n) => n + 1,
Bound::Excluded(&n) => n.saturating_add(1),
};
let end = match range.end_bound() {
Bound::Unbounded => arr.len(),
Bound::Included(&n) => n + 1,
Bound::Included(&n) => n.saturating_add(1),
Bound::Excluded(&n) => n,
};
+2 -2
View File
@@ -161,11 +161,11 @@ impl<'s, T> SliceVec<'s, T> {
use core::ops::Bound;
let start = match range.start_bound() {
Bound::Included(x) => *x,
Bound::Excluded(x) => x + 1,
Bound::Excluded(x) => x.saturating_add(1),
Bound::Unbounded => 0,
};
let end = match range.end_bound() {
Bound::Included(x) => x + 1,
Bound::Included(x) => x.saturating_add(1),
Bound::Excluded(x) => *x,
Bound::Unbounded => self.len,
};
+2 -2
View File
@@ -789,11 +789,11 @@ impl<A: Array> TinyVec<A> {
use core::ops::Bound;
let start = match range.start_bound() {
Bound::Included(x) => *x,
Bound::Excluded(x) => x + 1,
Bound::Excluded(x) => x.saturating_add(1),
Bound::Unbounded => 0,
};
let end = match range.end_bound() {
Bound::Included(x) => x + 1,
Bound::Included(x) => x.saturating_add(1),
Bound::Excluded(x) => *x,
Bound::Unbounded => self.len(),
};