From 7207276697de0fb1886737aee373d9172e3901ec Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 18 May 2020 15:07:37 +0200 Subject: [PATCH] AK: Make Utf32View::substring_view() with 0 length not crash Just make it hand out a zero-length Utf32View :^) --- AK/Utf32View.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AK/Utf32View.h b/AK/Utf32View.h index f75125a8e7b..89c0eefcead 100644 --- a/AK/Utf32View.h +++ b/AK/Utf32View.h @@ -34,6 +34,7 @@ namespace AK { class Utf32View { public: + Utf32View() { } Utf32View(const u32* codepoints, size_t length) : m_codepoints(codepoints) , m_length(length) @@ -46,6 +47,8 @@ public: Utf32View substring_view(size_t offset, size_t length) const { + if (length == 0) + return {}; ASSERT(offset < m_length); ASSERT(!Checked::addition_would_overflow(offset, length)); ASSERT((offset + length) <= m_length);