Xi: handle allocation failure in ProcXListInputDevices()

Reported in #1817:

xwayland-24.1.6/redhat-linux-build/../Xi/listdev.c:171:5:
 warning[-Wanalyzer-possible-null-dereference]:
 dereference of possibly-NULL ‘dev’
xwayland-24.1.6/redhat-linux-build/../Xi/listdev.c:379: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/2075>
This commit is contained in:
Alan Coopersmith 2025-10-05 17:37:48 -07:00 committed by Marge Bot
parent 7b18313e2a
commit 19c6195e71

View file

@ -363,6 +363,10 @@ ProcXListInputDevices(ClientPtr client)
/* allocate space for reply */
total_length = numdevs * sizeof(xDeviceInfo) + size + namesize;
devbuf = (char *) calloc(1, total_length);
if (!devbuf) {
free(skip);
return BadAlloc;
}
classbuf = devbuf + (numdevs * sizeof(xDeviceInfo));
namebuf = classbuf + size;
savbuf = devbuf;