Xi: some extra checks for validity of kbd and mouse.

Floating SDs are paired with themselves, so the paired device may not be a
proper keyboard or mouse. Put some extra checks in to avoid dereferencing a
nullpointer later.
This commit is contained in:
Peter Hutterer 2008-04-10 08:29:05 +09:30
parent 8e0a652930
commit 5a4c6621aa

View File

@ -730,11 +730,15 @@ ProcessOtherEvent(xEventPtr xE, DeviceIntPtr device, int count)
{
kbd = GetPairedDevice(device);
mouse = device;
if (!kbd->key) /* can happen with floating SDs */
kbd = NULL;
}
else
{
mouse = GetPairedDevice(device);
kbd = device;
if (!mouse->valuator || !mouse->button) /* may be float. SDs */
mouse = NULL;
}
xE->u.keyButtonPointer.state = (kbd) ? (kbd->key->state) : 0;
xE->u.keyButtonPointer.state |= (mouse) ? (mouse->button->state) : 0;