Xext/xres: avoid null dereference in ProcXResQueryClients()

Reported in #1817:

xwayland-24.1.6/redhat-linux-build/../Xext/xres.c:233:13: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘current_clients’
xwayland-24.1.6/redhat-linux-build/../Xext/xres.c:228:23: acquire_memory: this call could return NULL

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2072>
This commit is contained in:
Alan Coopersmith 2025-10-04 17:10:20 -07:00 committed by Marge Bot
parent 5e62aaaf57
commit 3da60c96a9

View file

@ -224,6 +224,8 @@ ProcXResQueryClients(ClientPtr client)
REQUEST_SIZE_MATCH(xXResQueryClientsReq);
current_clients = xallocarray(currentMaxClients, sizeof(int));
if (current_clients == NULL)
return BadAlloc;
num_clients = 0;
for (i = 0; i < currentMaxClients; i++) {