mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
AK: Always do bounds checking in Array::operator[]
This commit is contained in:
parent
b7c66233f6
commit
69d8ad52c4
Notes:
sideshowbarker
2024-07-18 21:53:12 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/69d8ad52c49
1 changed files with 4 additions and 4 deletions
|
@ -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<typename T2, size_t Size2>
|
||||
constexpr bool operator==(const Array<T2, Size2>& other) const { return span() == other.span(); }
|
||||
|
|
Loading…
Add table
Reference in a new issue