os: handle memory allocation failure in get_mcast_options()

Since this is in initial startup, and other errors in this function are
already fatal, just make allocation failure of this small structure be
fatal as well, since if the X server is already out of memory it will
be dying soon anyway.

Reported in #1817:
xwayland-24.1.6/redhat-linux-build/../os/xdmcp.c:1514:13:
 warning[-Wanalyzer-possible-null-dereference]:
  dereference of possibly-NULL ‘mcastinfo’
xwayland-24.1.6/redhat-linux-build/../os/xdmcp.c:1513:25:
 acquire_memory: this call could return NULL
xwayland-24.1.6/redhat-linux-build/../os/xdmcp.c:1514:13:
 danger: ‘mcastinfo’ could be NULL: unchecked value from (9)

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
This commit is contained in:
Alan Coopersmith 2026-03-29 16:07:20 -07:00
parent fde685eefe
commit f523ddfa3a

View file

@ -1518,7 +1518,7 @@ get_mcast_options(int argc, char **argv, int i)
else {
struct multicastinfo *mcastinfo, *mcl;
mcastinfo = malloc(sizeof(struct multicastinfo));
mcastinfo = XNFalloc(sizeof(struct multicastinfo));
mcastinfo->next = NULL;
mcastinfo->ai = firstai;
mcastinfo->hops = hopcount;