dix: make DeviceEnterLeaveEvent() anaylzer-friendly

The analyzer giving a false alarm on potential NULL-pointer deref here.
Even though that case can't happen, it's also not immediately clear
to the human reader.

To make both the analyzer as well human reader happier, reformulating
this function to by using fast-return pattern.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult
2025-05-07 13:01:20 +02:00
parent 9e8557ad02
commit aa9521776f

View File

@@ -4747,7 +4747,6 @@ DeviceEnterLeaveEvent(DeviceIntPtr mouse,
int mode, int detail, WindowPtr pWin, Window child)
{
GrabPtr grab = mouse->deviceGrab.grab;
xXIEnterEvent *event;
WindowPtr focus;
int filter;
int btlen, len, i;
@@ -4761,7 +4760,10 @@ DeviceEnterLeaveEvent(DeviceIntPtr mouse,
btlen = bytes_to_int32(btlen);
len = sizeof(xXIEnterEvent) + btlen * 4;
event = calloc(1, len);
xXIEnterEvent *event = calloc(1, len);
if (!event)
return;
event->type = GenericEvent;
event->extension = IReqCode;
event->evtype = type;