dix: Handle the case where a device cursor was removed correctly

In the case that the device cursor was the first in the list of cursors
the window knew about, unsetting the cursor could lead to a segfault
due to pPrev being NULL. Instead catch the condition and correctly remove
the node from the list. Since there is no cursor now set on the device,
we simply return success as the parent windows cursor will propogate
down later.

Signed-off-by: Peter Hutterer <peter@cs.unisa.edu.au>
This commit is contained in:
Benjamin Close 2008-02-15 13:36:34 +10:30 committed by Peter Hutterer
parent 24db282301
commit 660739c6bc

View File

@ -3823,8 +3823,14 @@ ChangeWindowDeviceCursor(WindowPtr pWin,
if (!pCursor) /* remove from list */
{
pPrev->next = pNode->next;
if(pPrev)
pPrev->next = pNode->next;
else
/* first item in list */
pWin->optional->deviceCursors = pNode->next;
xfree(pNode);
return Success;
}
} else