mirror of
https://github.com/openharmony/third_party_rust_tinyvec.git
synced 2026-07-19 14:23:33 -04:00
SliceVec fuzzer + overflow fix on usize::MAX ranges (#99)
* add slicevec fuzzer * prevent overflow on range calculation
This commit is contained in:
+2
-2
@@ -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(),
|
||||
};
|
||||
|
||||
@@ -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
@@ -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
@@ -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(),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user