From 7b7579e956a98ac54f64e69b457c90a1786e6750 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Tue, 6 May 2025 16:04:41 +0200 Subject: [PATCH] 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 3b34f8486..6e7b3e125 100644 --- a/dix/window.c +++ b/dix/window.c @@ -3486,17 +3486,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))