dix: protect ChangeWindowDeviceCursor() from allocation failure
On memory allocation failure, return BadAlloc instead of crashing. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
8b079ed198
commit
7b7579e956
|
@ -3486,17 +3486,17 @@ ChangeWindowDeviceCursor(WindowPtr pWin, DeviceIntPtr pDev, CursorPtr pCursor)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* no device cursor yet */
|
/* no device cursor yet */
|
||||||
DevCursNodePtr pNewNode;
|
|
||||||
|
|
||||||
if (!pCursor)
|
if (!pCursor)
|
||||||
return Success;
|
return Success;
|
||||||
|
|
||||||
pNewNode = malloc(sizeof(DevCursNodeRec));
|
DevCursNodePtr pNewNode = calloc(1, sizeof(DevCursNodeRec));
|
||||||
|
if (!pNewNode)
|
||||||
|
return BadAlloc;
|
||||||
|
|
||||||
pNewNode->dev = pDev;
|
pNewNode->dev = pDev;
|
||||||
pNewNode->next = pWin->optional->deviceCursors;
|
pNewNode->next = pWin->optional->deviceCursors;
|
||||||
pWin->optional->deviceCursors = pNewNode;
|
pWin->optional->deviceCursors = pNewNode;
|
||||||
pNode = pNewNode;
|
pNode = pNewNode;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pCursor && WindowParentHasDeviceCursor(pWin, pDev, pCursor))
|
if (pCursor && WindowParentHasDeviceCursor(pWin, pDev, pCursor))
|
||||||
|
|
Loading…
Reference in New Issue