From 19c6195e711d9f9fabbde1bea7a6393c4a4c3cd3 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 5 Oct 2025 17:37:48 -0700 Subject: [PATCH] Xi: handle allocation failure in ProcXListInputDevices() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Part-of: --- Xi/listdev.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Xi/listdev.c b/Xi/listdev.c index bf2f439a4..95f0d8103 100644 --- a/Xi/listdev.c +++ b/Xi/listdev.c @@ -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;