Commit ed3f55b9 authored by Martin Flöser's avatar Martin Flöser

[wayland] Fix heap-use-after-free in idle time plugin

We need to also destroy all idle objects when we tear down the
internal client connection. Otherwise the cleanup tries to free
the object after our Wayland connection is already destroyed.
parent db5a7989
......@@ -27,6 +27,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
Poller::Poller(QObject *parent)
: AbstractSystemPoller(parent)
{
connect(KWin::waylandServer(), &KWin::WaylandServer::terminatingInternalClientConnection, this,
[this] {
qDeleteAll(m_timeouts);
m_timeouts.clear();
delete m_seat;
m_seat = nullptr;
delete m_idle;
m_idle = nullptr;
}
);
}
Poller::~Poller() = default;
......
......@@ -79,6 +79,7 @@ WaylandServer::~WaylandServer()
void WaylandServer::destroyInternalConnection()
{
emit terminatingInternalClientConnection();
if (m_internalConnection.client) {
delete m_internalConnection.registry;
delete m_internalConnection.shm;
......
......@@ -157,6 +157,7 @@ public:
Q_SIGNALS:
void shellClientAdded(KWin::ShellClient*);
void shellClientRemoved(KWin::ShellClient*);
void terminatingInternalClientConnection();
private:
quint16 createClientId(KWayland::Server::ClientConnection *c);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment