diff options
author | Tom <tomut@yahoo.com> | 2020-09-15 16:09:10 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-09-16 15:57:12 +0200 |
commit | 6212f57755fd3854f6a0cb812cd095484e9a3249 (patch) | |
tree | 7ff17d2f759b873ec5aa647558a22a5cd9be9d08 /Services/WindowServer | |
parent | 961661ea1d9816b9ac99c15e418156e504e33cab (diff) | |
download | serenity-6212f57755fd3854f6a0cb812cd095484e9a3249.zip |
WindowServer: Make SetWindowTaskbarRect tolerant to non-existing windows
There is a window between windows disappearing (e.g. closing or crashes)
and the Taskbar process being notified. So it is entirely possible that
it may call SetWindowTaskbarRect() for a window and/or client id that no
longer exists. As the Taskbar process does not own these windows, this
should not be treated as a misbehaving application request. Instead, just
silently ignore the request. The Taskbar will be notified shortly after
that the window no longer exist and remove it from its list.
Fixes #3494
Diffstat (limited to 'Services/WindowServer')
-rw-r--r-- | Services/WindowServer/ClientConnection.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Services/WindowServer/ClientConnection.cpp b/Services/WindowServer/ClientConnection.cpp index 6244cdc5ac..cdb7d35a52 100644 --- a/Services/WindowServer/ClientConnection.cpp +++ b/Services/WindowServer/ClientConnection.cpp @@ -723,16 +723,18 @@ OwnPtr<Messages::WindowServer::GreetResponse> ClientConnection::handle(const Mes void ClientConnection::handle(const Messages::WindowServer::WM_SetWindowTaskbarRect& message) { + // Because the Taskbar (which should be the only user of this API) does not own the + // window or the client id, there is a possibility that it may send this message for + // a window or client that may have been destroyed already. This is not an error, + // and we should not call did_misbehave() for either. auto* client = ClientConnection::from_client_id(message.client_id()); - if (!client) { - did_misbehave("WM_SetWindowTaskbarRect: Bad client ID"); + if (!client) return; - } + auto it = client->m_windows.find(message.window_id()); - if (it == client->m_windows.end()) { - did_misbehave("WM_SetWindowTaskbarRect: Bad window ID"); + if (it == client->m_windows.end()) return; - } + auto& window = *(*it).value; window.set_taskbar_rect(message.rect()); } |