[client] Fix nullptr dereference in ConfinedPointer and LockedPointer
The setRegion call allows a null region. This means nullptr is an allowed value which can be passed to ConfinedPointer::setRegion and LockedPointer::setRegion. In that case we crash if we try to convert the Region into a wl_region. Thus add proper nullptr check, just like in PointerConstraints::lockPointer and ::confinePointer. Auto test adjusted to cover the condition.
This commit is contained in:
parent
a1990e9cc5
commit
49d57b342c
1 changed files with 10 additions and 0 deletions
|
@ -226,6 +226,11 @@ void TestPointerConstraints::testLockPointer()
|
||||||
surface->commit(Surface::CommitFlag::None);
|
surface->commit(Surface::CommitFlag::None);
|
||||||
QVERIFY(regionChangedSpy.wait());
|
QVERIFY(regionChangedSpy.wait());
|
||||||
QCOMPARE(serverLockedPointer->region(), QRegion(0, 5, 10, 20));
|
QCOMPARE(serverLockedPointer->region(), QRegion(0, 5, 10, 20));
|
||||||
|
// and unset region again
|
||||||
|
lockedPointer->setRegion(nullptr);
|
||||||
|
surface->commit(Surface::CommitFlag::None);
|
||||||
|
QVERIFY(regionChangedSpy.wait());
|
||||||
|
QCOMPARE(serverLockedPointer->region(), QRegion());
|
||||||
|
|
||||||
// let's lock the surface
|
// let's lock the surface
|
||||||
QSignalSpy lockedChangedSpy(serverLockedPointer.data(), &LockedPointerInterface::lockedChanged);
|
QSignalSpy lockedChangedSpy(serverLockedPointer.data(), &LockedPointerInterface::lockedChanged);
|
||||||
|
@ -326,6 +331,11 @@ void TestPointerConstraints::testConfinePointer()
|
||||||
surface->commit(Surface::CommitFlag::None);
|
surface->commit(Surface::CommitFlag::None);
|
||||||
QVERIFY(regionChangedSpy.wait());
|
QVERIFY(regionChangedSpy.wait());
|
||||||
QCOMPARE(serverConfinedPointer->region(), QRegion(0, 5, 10, 20));
|
QCOMPARE(serverConfinedPointer->region(), QRegion(0, 5, 10, 20));
|
||||||
|
// and unset region again
|
||||||
|
confinedPointer->setRegion(nullptr);
|
||||||
|
surface->commit(Surface::CommitFlag::None);
|
||||||
|
QVERIFY(regionChangedSpy.wait());
|
||||||
|
QCOMPARE(serverConfinedPointer->region(), QRegion());
|
||||||
|
|
||||||
// let's confine the surface
|
// let's confine the surface
|
||||||
QSignalSpy confinedChangedSpy(serverConfinedPointer.data(), &ConfinedPointerInterface::confinedChanged);
|
QSignalSpy confinedChangedSpy(serverConfinedPointer.data(), &ConfinedPointerInterface::confinedChanged);
|
||||||
|
|
Loading…
Reference in a new issue