From fd3d162331c7a1c27f259768362ed0f02d454c66 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Tue, 6 May 2025 16:14:05 +0200 Subject: [PATCH] os: xdmcp: handle allocation failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit | ../os/xdmcp.c: In function ‘get_mcast_options’: | ../os/xdmcp.c:1527:27: warning: dereference of possibly-NULL ‘mcastinfo’ [CWE-690] [-Wanalyzer-possible-null-dereference] | 1527 | mcastinfo->ai = firstai; | | ~~~~~~~~~~~~~~^~~~~~~~~ Signed-off-by: Enrico Weigelt, metux IT consult --- os/xdmcp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/os/xdmcp.c b/os/xdmcp.c index 955cee1b4..822d458af 100644 --- a/os/xdmcp.c +++ b/os/xdmcp.c @@ -1521,8 +1521,10 @@ get_mcast_options(int argc, char **argv, int i) else { struct multicastinfo *mcastinfo, *mcl; - mcastinfo = malloc(sizeof(struct multicastinfo)); - mcastinfo->next = NULL; + mcastinfo = calloc(1, sizeof(struct multicastinfo)); + if (!mcastinfo) + FatalError("Xserver: failed to allocate mcastinfo\n"); + mcastinfo->ai = firstai; mcastinfo->hops = hopcount;