From 0060fa48d41b58c4ab8f1b4017da660293a8961f Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Sun, 18 Jul 2021 00:19:16 +0430 Subject: [PATCH] AK: Don't return a null Utf32View when a zero-length one is requested There is still an offset to consider, a zero-length view is very different from a nonexistent string :P Co-authored-by: Timothy Flynn --- AK/Utf32View.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/AK/Utf32View.h b/AK/Utf32View.h index cdb5f4be19..d210ec7eaf 100644 --- a/AK/Utf32View.h +++ b/AK/Utf32View.h @@ -94,9 +94,7 @@ public: Utf32View substring_view(size_t offset, size_t length) const { - if (length == 0) - return {}; - VERIFY(offset < m_length); + VERIFY(offset <= m_length); VERIFY(!Checked::addition_would_overflow(offset, length)); VERIFY((offset + length) <= m_length); return Utf32View(m_code_points + offset, length);