From f3a6a589c894dc4134afe456a833ee3d600e355b Mon Sep 17 00:00:00 2001 From: Kuba314 <35199722+Kuba314@users.noreply.github.com> Date: Sun, 8 Sep 2024 11:46:40 +0200 Subject: [PATCH] LibWeb: Consider last resort font in font list Getting the first font in a font cascade list with an empty font list results in an OOTB index error. If the font list is empty, the last resort font should be returned instead. --- Userland/Libraries/LibGfx/FontCascadeList.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibGfx/FontCascadeList.h b/Userland/Libraries/LibGfx/FontCascadeList.h index 681021e82c0..be4181e9a86 100644 --- a/Userland/Libraries/LibGfx/FontCascadeList.h +++ b/Userland/Libraries/LibGfx/FontCascadeList.h @@ -20,7 +20,7 @@ public: size_t size() const { return m_fonts.size(); } bool is_empty() const { return m_fonts.is_empty() && !m_last_resort_font; } - Font const& first() const { return *m_fonts.first().font; } + Font const& first() const { return !m_fonts.is_empty() ? *m_fonts.first().font : *m_last_resort_font; } template void for_each_font_entry(Callback callback) const