mirror of
https://github.com/X11Libre/xserver.git
synced 2026-03-27 12:19:10 +00:00
dix: protect against alloc failure in ‘DeviceFocusEvent()
Fixes analyzer warning: | ../dix/enterleave.c: In function ‘DeviceFocusEvent’: | ../dix/enterleave.c:788:20: warning: dereference of possibly-NULL ‘xi2event’ [CWE-690] [-Wanalyzer-possible-null-dereference] | 788 | xi2event->type = GenericEvent; | ‘DoFocusEvents’: events 1-4 Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
@@ -771,7 +771,6 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
|
||||
WindowPtr pWin)
|
||||
{
|
||||
deviceFocus event;
|
||||
xXIFocusInEvent *xi2event;
|
||||
DeviceIntPtr mouse;
|
||||
int btlen, len, i;
|
||||
|
||||
@@ -783,7 +782,10 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
|
||||
btlen = bytes_to_int32(btlen);
|
||||
len = sizeof(xXIFocusInEvent) + btlen * 4;
|
||||
|
||||
xi2event = calloc(1, len);
|
||||
xXIFocusInEvent *xi2event = calloc(1, len);
|
||||
if (!xi2event)
|
||||
return;
|
||||
|
||||
xi2event->type = GenericEvent;
|
||||
xi2event->extension = IReqCode;
|
||||
xi2event->evtype = type;
|
||||
|
||||
Reference in New Issue
Block a user