[PATCH] Xi: check for NULL pointer before dereferences it in DeviceFocusEvent
Tiago Vignatti
tiago.vignatti at nokia.com
Fri Apr 16 08:42:22 PDT 2010
Both mouse and mouse->button are already used before their checking were being
performed. So check on the beginning.
Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
---
Xi/exevents.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/Xi/exevents.c b/Xi/exevents.c
index e680f6f..7a1f6cf 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1241,6 +1241,8 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
int btlen, len, i;
mouse = (IsMaster(dev) || dev->u.master) ? GetMaster(dev, MASTER_POINTER) : dev;
+ if (!mouse || !mouse->button)
+ FatalError("no device mouse found");
/* XI 2 event */
btlen = (mouse->button) ? bits_to_bytes(mouse->button->numButtons) : 0;
@@ -1261,7 +1263,7 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
xi2event->root_x = FP1616(mouse->spriteInfo->sprite->hot.x, 0);
xi2event->root_y = FP1616(mouse->spriteInfo->sprite->hot.y, 0);
- for (i = 0; mouse && mouse->button && i < mouse->button->numButtons; i++)
+ for (i = 0; i < mouse->button->numButtons; i++)
if (BitIsOn(mouse->button->down, i))
SetBit(&xi2event[1], i);
--
1.6.0.4
More information about the xorg-devel
mailing list