[PATCH] dix: check for NULL pointer before dereferences it in DeviceEnterLeaveEvent

Tiago Vignatti tiago.vignatti at nokia.com
Mon Apr 19 10:58:04 PDT 2010


mouse is already used before its checking should be performed. So check on the
beginning instead.
---
 dix/events.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/dix/events.c b/dix/events.c
index 6541652..8bec8af 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -4360,6 +4360,10 @@ DeviceEnterLeaveEvent(
         (mode == XINotifyPassiveUngrab && type == XI_Enter))
         return;
 
+    if (!mouse)
+        return;
+    grab = mouse->deviceGrab.grab;
+
     btlen = (mouse->button) ? bits_to_bytes(mouse->button->numButtons) : 0;
     btlen = bytes_to_int32(btlen);
     len = sizeof(xXIEnterEvent) + btlen * 4;
@@ -4378,7 +4382,7 @@ DeviceEnterLeaveEvent(
     event->root_x       = FP1616(mouse->spriteInfo->sprite->hot.x, 0);
     event->root_y       = FP1616(mouse->spriteInfo->sprite->hot.y, 0);
 
-    for (i = 0; mouse && mouse->button && i < mouse->button->numButtons; i++)
+    for (i = 0; mouse->button && i < mouse->button->numButtons; i++)
         if (BitIsOn(mouse->button->down, i))
             SetBit(&event[1], i);
 
-- 
1.6.0.4



More information about the xorg-devel mailing list