dix: fix crash on shutdown if a disabled device is still grabbed (XI1 grab)
A disabled device doesn't have a sprite (less so a sprite->win) and triggers a NULL-pointer dereference on shutdown when all active grabs are released as part of the cleanup. Fix this by checking for sprite being non-null and setting the focus window to the NullWindow if it is. The rest of the patch just attempts to make things more readable. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
parent
0c7109f321
commit
4b7f00346d
16
dix/events.c
16
dix/events.c
|
@ -1593,13 +1593,10 @@ DeactivateKeyboardGrab(DeviceIntPtr keybd)
|
||||||
{
|
{
|
||||||
GrabPtr grab = keybd->deviceGrab.grab;
|
GrabPtr grab = keybd->deviceGrab.grab;
|
||||||
DeviceIntPtr dev;
|
DeviceIntPtr dev;
|
||||||
WindowPtr focusWin = keybd->focus ? keybd->focus->win
|
WindowPtr focusWin;
|
||||||
: keybd->spriteInfo->sprite->win;
|
|
||||||
Bool wasImplicit = (keybd->deviceGrab.fromPassiveGrab &&
|
Bool wasImplicit = (keybd->deviceGrab.fromPassiveGrab &&
|
||||||
keybd->deviceGrab.implicitGrab);
|
keybd->deviceGrab.implicitGrab);
|
||||||
|
|
||||||
if (focusWin == FollowKeyboardWin)
|
|
||||||
focusWin = inputInfo.keyboard->focus->win;
|
|
||||||
if (keybd->valuator)
|
if (keybd->valuator)
|
||||||
keybd->valuator->motionHintWindow = NullWindow;
|
keybd->valuator->motionHintWindow = NullWindow;
|
||||||
keybd->deviceGrab.grab = NullGrab;
|
keybd->deviceGrab.grab = NullGrab;
|
||||||
|
@ -1610,6 +1607,17 @@ DeactivateKeyboardGrab(DeviceIntPtr keybd)
|
||||||
if (dev->deviceGrab.sync.other == grab)
|
if (dev->deviceGrab.sync.other == grab)
|
||||||
dev->deviceGrab.sync.other = NullGrab;
|
dev->deviceGrab.sync.other = NullGrab;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (keybd->focus)
|
||||||
|
focusWin = keybd->focus->win;
|
||||||
|
else if (keybd->spriteInfo->sprite)
|
||||||
|
focusWin = keybd->spriteInfo->sprite->win;
|
||||||
|
else
|
||||||
|
focusWin = NullWindow;
|
||||||
|
|
||||||
|
if (focusWin == FollowKeyboardWin)
|
||||||
|
focusWin = inputInfo.keyboard->focus->win;
|
||||||
|
|
||||||
DoFocusEvents(keybd, grab->window, focusWin, NotifyUngrab);
|
DoFocusEvents(keybd, grab->window, focusWin, NotifyUngrab);
|
||||||
|
|
||||||
if (!wasImplicit && grab->grabtype == XI2)
|
if (!wasImplicit && grab->grabtype == XI2)
|
||||||
|
|
Loading…
Reference in New Issue