From 7a270b5d7894990ea09df70d638ce1b1741f3b54 Mon Sep 17 00:00:00 2001 From: Weng Xuetian Date: Mon, 13 Dec 2021 09:29:16 -0800 Subject: [PATCH] Use QPointer to monitor input method server connection. Input method may crash and leave a dangling pointer. DBus interface may access the invalid pointer and crash kwin. --- src/wayland_server.cpp | 5 +++++ src/wayland_server.h | 6 ++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/wayland_server.cpp b/src/wayland_server.cpp index e3ed4601eb..c4f738eddd 100644 --- a/src/wayland_server.cpp +++ b/src/wayland_server.cpp @@ -206,6 +206,11 @@ KWaylandServer::ClientConnection *WaylandServer::xWaylandConnection() const return m_xwaylandConnection; } +KWaylandServer::ClientConnection *WaylandServer::inputMethodConnection() const +{ + return m_inputMethodServerConnection; +} + void WaylandServer::registerShellClient(AbstractClient *client) { if (client->isLockScreen()) { diff --git a/src/wayland_server.h b/src/wayland_server.h index e1bbcab17b..bf1ba6eee5 100644 --- a/src/wayland_server.h +++ b/src/wayland_server.h @@ -180,9 +180,7 @@ public: void initWorkspace(); KWaylandServer::ClientConnection *xWaylandConnection() const; - KWaylandServer::ClientConnection *inputMethodConnection() const { - return m_inputMethodServerConnection; - } + KWaylandServer::ClientConnection *inputMethodConnection() const; KWaylandServer::ClientConnection *screenLockerClientConnection() const { return m_screenLockerClientConnection; } @@ -266,7 +264,7 @@ private: QSet m_linuxDmabufBuffers; QPointer m_xwaylandConnection; KWaylandServer::InputMethodV1Interface *m_inputMethod = nullptr; - KWaylandServer::ClientConnection *m_inputMethodServerConnection = nullptr; + QPointer m_inputMethodServerConnection; KWaylandServer::ClientConnection *m_screenLockerClientConnection = nullptr; KWaylandServer::XdgForeignV2Interface *m_XdgForeign = nullptr; KWaylandServer::KeyStateInterface *m_keyState = nullptr;