From 7e19399f1a7ca33c7a8a0cec30f61beb68a510e3 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Tue, 6 May 2025 16:04:41 +0200 Subject: [PATCH] (!1967) dix: protect ChangeWindowDeviceCursor() from allocation failure On memory allocation failure, return BadAlloc instead of crashing. Signed-off-by: Enrico Weigelt, metux IT consult --- dix/window.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dix/window.c b/dix/window.c index 2fc9ac03e..de6d617ce 100644 --- a/dix/window.c +++ b/dix/window.c @@ -3487,17 +3487,17 @@ ChangeWindowDeviceCursor(WindowPtr pWin, DeviceIntPtr pDev, CursorPtr pCursor) } else { /* no device cursor yet */ - DevCursNodePtr pNewNode; - if (!pCursor) return Success; - pNewNode = malloc(sizeof(DevCursNodeRec)); + DevCursNodePtr pNewNode = calloc(1, sizeof(DevCursNodeRec)); + if (!pNewNode) + return BadAlloc; + pNewNode->dev = pDev; pNewNode->next = pWin->optional->deviceCursors; pWin->optional->deviceCursors = pNewNode; pNode = pNewNode; - } if (pCursor && WindowParentHasDeviceCursor(pWin, pDev, pCursor))