summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-10-22 18:23:38 +0200
committerAndreas Kling <kling@serenityos.org>2020-10-22 18:24:15 +0200
commit0b746075d89475a18499618b69efcd2aac412486 (patch)
tree3f94fd6c383a1aae6abb2a976a050b6c1127310d /Libraries
parent0341e3fde73aa44cb5b2b4037b969fa74a0ea369 (diff)
downloadserenity-0b746075d89475a18499618b69efcd2aac412486.zip
LibGUI: Tolerate Window::set_icon(nullptr)
Don't try to dereference a null icon. Instead just set a 16x16 empty bitmap as the window icon. This looks like the crash mentioned in #3817.
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibGUI/Window.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/Libraries/LibGUI/Window.cpp b/Libraries/LibGUI/Window.cpp
index 1618e891c3..e71a939d69 100644
--- a/Libraries/LibGUI/Window.cpp
+++ b/Libraries/LibGUI/Window.cpp
@@ -682,9 +682,11 @@ void Window::set_icon(const Gfx::Bitmap* icon)
if (m_icon == icon)
return;
- m_icon = create_shared_bitmap(Gfx::BitmapFormat::RGBA32, icon->size());
+ Gfx::IntSize icon_size = icon ? icon->size() : Gfx::IntSize(16, 16);
+
+ m_icon = create_shared_bitmap(Gfx::BitmapFormat::RGBA32, icon_size);
ASSERT(m_icon);
- {
+ if (icon) {
Painter painter(*m_icon);
painter.blit({ 0, 0 }, *icon, icon->rect());
}