diff options
author | Tiago Vignatti <tiago.vignatti@nokia.com> | 2010-04-16 18:01:41 +0300 |
---|---|---|
committer | Tiago Vignatti <tiago.vignatti@nokia.com> | 2010-04-21 18:07:19 +0300 |
commit | 057c147541bde6f0cbe22ca069b43a97ddc95baf (patch) | |
tree | b7eeaa2f3d1c23d9044b6021fbf897c1f7301da7 | |
parent | 7f457351d2a09013cd57fcb2f95c0d6f56bfaccb (diff) |
Xi: check for NULL pointer before dereferences it in ListButtonInfo
Both dev and dev->button are already used before their checking were being
performed. So check on the beginning.
Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
-rw-r--r-- | Xi/xiquerydevice.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c index 435868de2..47ab688fd 100644 --- a/Xi/xiquerydevice.c +++ b/Xi/xiquerydevice.c @@ -247,6 +247,9 @@ ListButtonInfo(DeviceIntPtr dev, xXIButtonInfo* info, Bool reportState) int mask_len; int i; + if (!dev || !dev->button) + return 0; + mask_len = bytes_to_int32(bits_to_bytes(dev->button->numButtons)); info->type = ButtonClass; @@ -259,7 +262,7 @@ ListButtonInfo(DeviceIntPtr dev, xXIButtonInfo* info, Bool reportState) memset(bits, 0, mask_len * 4); if (reportState) - for (i = 0; dev && dev->button && i < dev->button->numButtons; i++) + for (i = 0; i < dev->button->numButtons; i++) if (BitIsOn(dev->button->down, i)) SetBit(bits, i); |