From 3e9f7a5504ab41d845e88f293d8498c963d8a7d8 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Wed, 21 Mar 2007 02:35:31 +0200 Subject: [PATCH] XFree86 DGA: Guard against NULL pointer dereferences. Ass, u, me ... --- hw/xfree86/common/xf86Xinput.c | 38 ++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c index c9c8059c0..17ffed899 100644 --- a/hw/xfree86/common/xf86Xinput.c +++ b/hw/xfree86/common/xf86Xinput.c @@ -423,17 +423,19 @@ xf86PostMotionEvent(DeviceIntPtr device, #if XFreeXDGA if (first_valuator == 0 && num_valuators >= 2) { - index = miPointerGetScreen(inputInfo.pointer)->myNum; - if (is_absolute) { - dx = valuators[0] - device->valuator->lastx; - dy = valuators[1] - device->valuator->lasty; + if (miPointerGetScreen(inputInfo.pointer)) { + index = miPointerGetScreen(inputInfo.pointer)->myNum; + if (is_absolute) { + dx = valuators[0] - device->valuator->lastx; + dy = valuators[1] - device->valuator->lasty; + } + else { + dx = valuators[0]; + dy = valuators[1]; + } + if (DGAStealMotionEvent(index, dx, dy)) + goto out; } - else { - dx = valuators[0]; - dy = valuators[1]; - } - if (DGAStealMotionEvent(index, dx, dy)) - goto out; } #endif @@ -505,9 +507,11 @@ xf86PostButtonEvent(DeviceIntPtr device, int index; #if XFreeXDGA - index = miPointerGetScreen(inputInfo.pointer)->myNum; - if (DGAStealButtonEvent(index, button, is_down)) - return; + if (miPointerGetScreen(inputInfo.pointer)) { + index = miPointerGetScreen(inputInfo.pointer)->myNum; + if (DGAStealButtonEvent(index, button, is_down)) + return; + } #endif valuators = xcalloc(sizeof(int), num_valuators); @@ -588,9 +592,11 @@ xf86PostKeyboardEvent(DeviceIntPtr device, int index; #if XFreeXDGA - index = miPointerGetScreen(inputInfo.pointer)->myNum; - if (DGAStealKeyEvent(index, key_code, is_down)) - return; + if (miPointerGetScreen(inputInfo.pointer)) { + index = miPointerGetScreen(inputInfo.pointer)->myNum; + if (DGAStealKeyEvent(index, key_code, is_down)) + return; + } #endif if (!xf86Events)