From 9f6c969aba1f9cc72640cfc79450ff266cdcbac1 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Wed, 7 Aug 2024 16:49:11 -0400 Subject: [PATCH] Don't process pad button events from a device that has been removed This fixes a rare crash where we may dereference a null TabletV2Interface in findAndAdoptPad. This can happen because the underlying device disappears, and we call libinput_device_group_set_user_data (what tabletPadId.data points to) to reset the user data to null. Similar to what we do to tablet tool events (see tabletToolEvent), we should check if this is null before continuing. Fixes KWIN-3R6 --- src/input.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/input.cpp b/src/input.cpp index b46732b334..6eb27714f4 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -2399,7 +2399,13 @@ public: return nullptr; } + // NOTE: tablet may be nullptr when the device is removed (see ::removeDevice) but events from the tool + // may still happen. auto tablet = static_cast(tabletPadId.data); + if (!tablet) { + return nullptr; + } + SurfaceInterface *surface = window->surface(); auto pad = tablet->pad(); if (!pad) {