mirror of
https://github.com/ml-explore/mlx.git
synced 2025-12-16 01:49:05 +08:00
fix small vector indexing checks
This commit is contained in:
@@ -302,7 +302,7 @@ class SmallVector {
|
||||
}
|
||||
|
||||
T& at(int index) {
|
||||
if (index >= size()) {
|
||||
if (index < 0 || index >= size()) {
|
||||
throw std::out_of_range("SmallVector out of range.");
|
||||
}
|
||||
return begin_[index];
|
||||
@@ -312,7 +312,7 @@ class SmallVector {
|
||||
}
|
||||
|
||||
T& operator[](int index) {
|
||||
assert(size() > index);
|
||||
assert(index >= 0 && size() > index);
|
||||
return begin_[index];
|
||||
}
|
||||
const T& operator[](int index) const {
|
||||
|
||||
Reference in New Issue
Block a user