From 6212f57755fd3854f6a0cb812cd095484e9a3249 Mon Sep 17 00:00:00 2001 From: Tom Date: Tue, 15 Sep 2020 16:09:10 -0600 Subject: 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 --- Services/WindowServer/ClientConnection.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'Services/WindowServer') 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 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()); } -- cgit v1.2.3