1 From 622cf1834725c3348cfdc41c12e39b327011c836 Mon Sep 17 00:00:00 2001 |
|
2 From: Alan Coopersmith <[email protected]> |
|
3 Date: Sat, 12 Sep 2009 20:18:06 -0700 |
|
4 Subject: [PATCH] Fix crashes due to MouseBlockHandler/MouseWakeupHandler with invalid devices |
|
5 |
|
6 Don't install the handlers if devices failed to open/initalize. |
|
7 Remove the handlers when disabling Emulate3Soft mode, since otherwise |
|
8 they'll be left around when device is closed & device structs are freed. |
|
9 |
|
10 Signed-off-by: Alan Coopersmith <[email protected]> |
|
11 --- |
|
12 src/mouse.c | 18 +++++++++++------- |
|
13 1 files changed, 11 insertions(+), 7 deletions(-) |
|
14 |
|
15 diff --git a/src/mouse.c b/src/mouse.c |
|
16 index 23dc726..8347be9 100644 |
|
17 --- a/src/mouse.c |
|
18 +++ b/src/mouse.c |
|
19 @@ -1691,6 +1691,11 @@ MouseProc(DeviceIntPtr device, int what) |
|
20 } |
|
21 xf86FlushInput(pInfo->fd); |
|
22 xf86AddEnabledDevice(pInfo); |
|
23 + if (pMse->emulate3Buttons || pMse->emulate3ButtonsSoft) { |
|
24 + RegisterBlockAndWakeupHandlers (MouseBlockHandler, |
|
25 + MouseWakeupHandler, |
|
26 + (pointer) pInfo); |
|
27 + } |
|
28 } |
|
29 } |
|
30 } |
|
31 @@ -1701,11 +1706,6 @@ MouseProc(DeviceIntPtr device, int what) |
|
32 pMse->wheelButtonExpires = GetTimeInMillis (); |
|
33 device->public.on = TRUE; |
|
34 FlushButtons(pMse); |
|
35 - if (pMse->emulate3Buttons || pMse->emulate3ButtonsSoft) |
|
36 - { |
|
37 - RegisterBlockAndWakeupHandlers (MouseBlockHandler, MouseWakeupHandler, |
|
38 - (pointer) pInfo); |
|
39 - } |
|
40 break; |
|
41 |
|
42 case DEVICE_OFF: |
|
43 @@ -1720,7 +1720,8 @@ MouseProc(DeviceIntPtr device, int what) |
|
44 pInfo->fd = -1; |
|
45 if (pMse->emulate3Buttons || pMse->emulate3ButtonsSoft) |
|
46 { |
|
47 - RemoveBlockAndWakeupHandlers (MouseBlockHandler, MouseWakeupHandler, |
|
48 + RemoveBlockAndWakeupHandlers (MouseBlockHandler, |
|
49 + MouseWakeupHandler, |
|
50 (pointer) pInfo); |
|
51 } |
|
52 } |
|
53 @@ -1967,7 +1968,10 @@ Emulate3ButtonsSoft(InputInfoPtr pInfo) |
|
54 buttonTimer(pInfo); |
|
55 |
|
56 xf86Msg(X_INFO,"3rd Button detected: disabling emulate3Button\n"); |
|
57 - |
|
58 + |
|
59 + RemoveBlockAndWakeupHandlers (MouseBlockHandler, MouseWakeupHandler, |
|
60 + (pointer) pInfo); |
|
61 + |
|
62 return FALSE; |
|
63 } |
|
64 |
|
65 -- |
|
66 1.5.6.5 |
|
67 |
|