From 91405109902e1808fe4671c13650a3fd372fdce3 Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Wed, 29 Feb 2012 14:43:16 +0100 Subject: [PATCH] Avoid crash on button events on device without valuators. Signed-off-by: Michal Suchanek --- dix/getevents.c | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-) diff --git a/dix/getevents.c b/dix/getevents.c index 058fa8a..958c6d6 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -198,6 +198,8 @@ set_valuators(DeviceIntPtr dev, DeviceEvent* event, ValuatorMask *mask) { int i; + if (!dev->valuator) + return; /* Set the data to the previous value for unset absolute axes. The values * may be used when sent as part of an XI 1.x valuator event. */ for (i = 0; i < valuator_mask_size(mask); i++) @@ -205,13 +207,15 @@ set_valuators(DeviceIntPtr dev, DeviceEvent* event, ValuatorMask *mask) if (valuator_mask_isset(mask, i)) { SetBit(event->valuators.mask, i); - if (valuator_get_mode(dev, i) == Absolute) + if ((dev->valuator->numAxes < i) || + (valuator_get_mode(dev, i) == Absolute)) SetBit(event->valuators.mode, i); event->valuators.data[i] = valuator_mask_get(mask, i); event->valuators.data_frac[i] = dev->last.remainder[i] * (1 << 16) * (1 << 16); } - else if (valuator_get_mode(dev, i) == Absolute) + else if ((dev->valuator->numAxes < i) && + (valuator_get_mode(dev, i) == Absolute)) event->valuators.data[i] = dev->valuator->axisVal[i]; } } @@ -640,7 +644,7 @@ clipAxis(DeviceIntPtr pDev, int axisNum, int *val) { AxisInfoPtr axis; - if (axisNum >= pDev->valuator->numAxes) + if (!pDev->valuator || axisNum >= pDev->valuator->numAxes) return; axis = pDev->valuator->axes + axisNum; @@ -1185,7 +1189,8 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons if (flags & POINTER_ABSOLUTE) { - if (flags & POINTER_SCREEN) /* valuators are in screen coords */ + if ((flags & POINTER_SCREEN) && /* valuators are in screen coords */ + pDev->valuator && (pDev->valuator->numAxes >= 2)) { int scaled; -- 1.7.9