From a557f83f8c30c5f778351ed52228fba44e177c3c Mon Sep 17 00:00:00 2001 From: Max Wipfli Date: Sun, 30 May 2021 16:07:07 +0200 Subject: [PATCH] AK: Verify that m_impl is non-null in String::operator[] This helps to find bugs where null strings are indexed into with operator[], as this would previously only report a RefPtr null dereference. --- AK/String.h | 1 + 1 file changed, 1 insertion(+) diff --git a/AK/String.h b/AK/String.h index 56ef416200..c6e6e468b4 100644 --- a/AK/String.h +++ b/AK/String.h @@ -160,6 +160,7 @@ public: [[nodiscard]] ALWAYS_INLINE const char& operator[](size_t i) const { + VERIFY(!is_null()); return (*m_impl)[i]; }