mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
AK: Add assertions to FixedArray::operator[]
Let's catch ourselves if we ever index out of bounds into one of these.
This commit is contained in:
parent
6a4b376021
commit
c48acafcba
Notes:
sideshowbarker
2024-07-19 10:17:13 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/c48acafcbaa
1 changed files with 11 additions and 2 deletions
|
@ -45,8 +45,17 @@ public:
|
|||
|
||||
size_t size() const { return m_size; }
|
||||
|
||||
T& operator[](size_t index) { return m_elements[index]; }
|
||||
const T& operator[](size_t index) const { return m_elements[index]; }
|
||||
T& operator[](size_t index)
|
||||
{
|
||||
ASSERT(index < m_size);
|
||||
return m_elements[index];
|
||||
}
|
||||
|
||||
const T& operator[](size_t index) const
|
||||
{
|
||||
ASSERT(index < m_size);
|
||||
return m_elements[index];
|
||||
}
|
||||
|
||||
void resize(size_t new_size)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue