[client] Properly track enteredSurface in Keyboard

Summary:
ASAN found a heap-use-after-free when deleting the focused keyboard
surface in the client library. Keyboard did not track the lifetime of
the focused surface and thus one can access already freed memory.

Test Plan: Adjusted auto test to verify the variable gets cleared

Reviewers: #frameworks, #plasma

Subscribers: plasma-devel

Tags: #plasma_on_wayland, #frameworks

Differential Revision: https://phabricator.kde.org/D6741
This commit is contained in:
Martin Flöser 2017-07-16 18:36:14 +02:00
parent 9266a94400
commit 63102e1215

View file

@ -1562,7 +1562,9 @@ void TestWaylandSeat::testKeyboard()
QSignalSpy serverSurfaceDestroyedSpy(serverSurface, &QObject::destroyed); QSignalSpy serverSurfaceDestroyedSpy(serverSurface, &QObject::destroyed);
QVERIFY(serverSurfaceDestroyedSpy.isValid()); QVERIFY(serverSurfaceDestroyedSpy.isValid());
QCOMPARE(keyboard->enteredSurface(), s);
delete s; delete s;
QVERIFY(!keyboard->enteredSurface());
QVERIFY(leftSpy.wait()); QVERIFY(leftSpy.wait());
QCOMPARE(serverSurfaceDestroyedSpy.count(), 1); QCOMPARE(serverSurfaceDestroyedSpy.count(), 1);
QVERIFY(!m_seatInterface->focusedKeyboardSurface()); QVERIFY(!m_seatInterface->focusedKeyboardSurface());