From 69d8ad52c497b56d316c4a142efc32883ad0d83d Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 27 Feb 2021 09:12:44 +0100 Subject: [PATCH] AK: Always do bounds checking in Array::operator[] --- AK/Array.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/AK/Array.h b/AK/Array.h index 19e15f4e635..d2cda3092f5 100644 --- a/AK/Array.h +++ b/AK/Array.h @@ -44,12 +44,12 @@ struct Array { constexpr const T& at(size_t index) const { VERIFY(index < size()); - return (*this)[index]; + return __data[index]; } constexpr T& at(size_t index) { VERIFY(index < size()); - return (*this)[index]; + return __data[index]; } constexpr const T& front() const { return at(0); } @@ -60,8 +60,8 @@ struct Array { constexpr bool is_empty() const { return size() == 0; } - constexpr const T& operator[](size_t index) const { return __data[index]; } - constexpr T& operator[](size_t index) { return __data[index]; } + constexpr const T& operator[](size_t index) const { return at(index); } + constexpr T& operator[](size_t index) { return at(index); } template constexpr bool operator==(const Array& other) const { return span() == other.span(); }