From 660739c6bc84cb74f43a277052ce163fae654417 Mon Sep 17 00:00:00 2001 From: Benjamin Close Date: Fri, 15 Feb 2008 13:36:34 +1030 Subject: [PATCH] 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 --- dix/window.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dix/window.c b/dix/window.c index 3b69e4547..a941dacd7 100644 --- a/dix/window.c +++ b/dix/window.c @@ -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