From 29f39cf0726dcc8c5689791f7eff889d55aa84c5 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 29 Mar 2026 16:00:55 -0700 Subject: [PATCH] os: handle memory allocation failure in set_font_authorizations() 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/../os/utils.c:1108:9: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘result’ xwayland-24.1.6/redhat-linux-build/../os/utils.c:1108:9: danger: ‘malloc((long unsigned int)len + 18)’ could be NULL: unchecked value from (3) Signed-off-by: Alan Coopersmith Part-of: --- os/utils.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/os/utils.c b/os/utils.c index 6df21f7db..97295f2c1 100644 --- a/os/utils.c +++ b/os/utils.c @@ -841,8 +841,14 @@ set_font_authorizations(char **authorizations, int *authlen, void *client) len = strlen(hnameptr) + 1; result = calloc(1, len + sizeof(AUTHORIZATION_NAME) + 4); - if (!result) + if (result == NULL) { +#if defined(HAVE_GETADDRINFO) + if (ai) { + freeaddrinfo(ai); + } +#endif return 0; + } p = result; *p++ = sizeof(AUTHORIZATION_NAME) >> 8;