1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 21:28:14 +00:00

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
This commit is contained in:
Tom 2020-09-15 16:09:10 -06:00 committed by Andreas Kling
parent 961661ea1d
commit 6212f57755

View file

@ -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());
}