diff options
author | Matthew Jones <matthewbjones85@gmail.com> | 2021-06-02 21:21:57 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-03 08:27:57 +0200 |
commit | 0ff09d4f745c6418420a9224ee0f2587d806900c (patch) | |
tree | 822eda6ac4662e34e417afad941dcd9bb2baad5b /Userland/Services | |
parent | ef92493abaeae1334e829dfcd05554a843a0be35 (diff) | |
download | serenity-0ff09d4f745c6418420a9224ee0f2587d806900c.zip |
WindowServer: Add sanity checks to `create_window` IPC
Diffstat (limited to 'Userland/Services')
-rw-r--r-- | Userland/Services/WindowServer/ClientConnection.cpp | 8 | ||||
-rw-r--r-- | Userland/Services/WindowServer/Window.cpp | 3 | ||||
-rw-r--r-- | Userland/Services/WindowServer/WindowType.h | 1 |
3 files changed, 10 insertions, 2 deletions
diff --git a/Userland/Services/WindowServer/ClientConnection.cpp b/Userland/Services/WindowServer/ClientConnection.cpp index a630230906..20d1985cdc 100644 --- a/Userland/Services/WindowServer/ClientConnection.cpp +++ b/Userland/Services/WindowServer/ClientConnection.cpp @@ -465,6 +465,11 @@ Messages::WindowServer::CreateWindowResponse ClientConnection::create_window(Gfx } } + if (type < 0 || type >= (i32)WindowType::_Count) { + did_misbehave("CreateWindow with a bad type"); + return nullptr; + } + int window_id = m_next_window_id++; auto window = Window::construct(*this, (WindowType)type, window_id, modal, minimizable, frameless, resizable, fullscreen, accessory, parent_window); @@ -492,7 +497,8 @@ Messages::WindowServer::CreateWindowResponse ClientConnection::create_window(Gfx window->set_alpha_hit_threshold(alpha_hit_threshold); window->set_size_increment(size_increment); window->set_base_size(base_size); - window->set_resize_aspect_ratio(resize_aspect_ratio); + if (resize_aspect_ratio.has_value() && !resize_aspect_ratio.value().is_null()) + window->set_resize_aspect_ratio(resize_aspect_ratio); window->invalidate(true, true); if (window->type() == WindowType::Applet) AppletManager::the().add_applet(*window); diff --git a/Userland/Services/WindowServer/Window.cpp b/Userland/Services/WindowServer/Window.cpp index 09d6da2ec3..8eba0a07e2 100644 --- a/Userland/Services/WindowServer/Window.cpp +++ b/Userland/Services/WindowServer/Window.cpp @@ -208,7 +208,8 @@ void Window::nudge_into_desktop(bool force_titlebar_visible) void Window::set_minimum_size(const Gfx::IntSize& size) { - VERIFY(!size.is_empty()); + if (size.is_null()) + return; if (m_minimum_size == size) return; diff --git a/Userland/Services/WindowServer/WindowType.h b/Userland/Services/WindowServer/WindowType.h index 59c28c690f..49e89cabd6 100644 --- a/Userland/Services/WindowServer/WindowType.h +++ b/Userland/Services/WindowServer/WindowType.h @@ -20,6 +20,7 @@ enum class WindowType { Desktop, ToolWindow, AppletArea, + _Count }; } |