From 6343622c6783a6167744941f6a3d49b3afdf93ff Mon Sep 17 00:00:00 2001 From: Ronan Collobert Date: Fri, 31 Oct 2025 11:46:36 -0700 Subject: [PATCH] fix small vector indexing checks --- mlx/small_vector.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mlx/small_vector.h b/mlx/small_vector.h index cf3467cbc..e0a0a76b4 100644 --- a/mlx/small_vector.h +++ b/mlx/small_vector.h @@ -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 {