From 196bf5e1dac42ce7f218b08e431dd7c3e15cc843 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 22 Mar 2020 18:21:29 +0100 Subject: [PATCH] Assert index is not negative for List. --- src/Collections/List.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Collections/List.hpp b/src/Collections/List.hpp index f14aa19..5f70a61 100644 --- a/src/Collections/List.hpp +++ b/src/Collections/List.hpp @@ -22,7 +22,7 @@ namespace Arbutils::Collections { inline const ValueT& At(size_t index) const { #ifndef NO_ASSERT - if (index >= _vector.size()) { + if (index >= _vector.size() || index < 0) { std::stringstream ss; ss << "Index " << index << " is out of bounds."; throw std::logic_error(ss.str()); @@ -32,7 +32,7 @@ namespace Arbutils::Collections { } inline ValueT& At(size_t index) { #ifndef NO_ASSERT - if (index >= _vector.size()) { + if (index >= _vector.size() || index < 0) { std::stringstream ss; ss << "Index " << index << " is out of bounds."; throw std::logic_error(ss.str());