From 0167b7d7b0013391f8dd38c2b79fb65238f4ac21 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Tue, 27 Dec 2022 10:21:31 +0000 Subject: [PATCH] libinput: Ignore touch events without outputs A touch device could have no output object assigned due to the screen being disabled, queued events or malconfiguration. Using output would crash. Touch up is guarded so that we have matching pairs. BUG: 463385 --- src/backends/libinput/connection.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/backends/libinput/connection.cpp b/src/backends/libinput/connection.cpp index 8e8f2c6ede..a85734e354 100644 --- a/src/backends/libinput/connection.cpp +++ b/src/backends/libinput/connection.cpp @@ -380,6 +380,10 @@ void Connection::processEvents() #ifndef KWIN_BUILD_TESTING TouchEvent *te = static_cast(event.get()); const auto *output = te->device()->output(); + if (!output) { + qCWarning(KWIN_LIBINPUT) << "Touch down received for device with no output assigned"; + break; + } const QPointF globalPos = devicePointToGlobalPosition(te->absolutePos(output->modeSize()), output); Q_EMIT te->device()->touchDown(te->id(), globalPos, te->time(), te->device()); break; @@ -387,6 +391,10 @@ void Connection::processEvents() } case LIBINPUT_EVENT_TOUCH_UP: { TouchEvent *te = static_cast(event.get()); + const auto *output = te->device()->output(); + if (!output) { + break; + } Q_EMIT te->device()->touchUp(te->id(), te->time(), te->device()); break; } @@ -394,6 +402,9 @@ void Connection::processEvents() #ifndef KWIN_BUILD_TESTING TouchEvent *te = static_cast(event.get()); const auto *output = te->device()->output(); + if (!output) { + break; + } const QPointF globalPos = devicePointToGlobalPosition(te->absolutePos(output->modeSize()), output); Q_EMIT te->device()->touchMotion(te->id(), globalPos, te->time(), te->device()); break;