os: util: protect set_font_authorizations() from allocation failure

| ../os/utils.c: In function ‘set_font_authorizations’:
| ../os/utils.c:863:14: warning: dereference of possibly-NULL ‘result’ [CWE-690] [-Wanalyzer-possible-null-dereference]
|   863 |         *p++ = sizeof(AUTHORIZATION_NAME) >> 8;
|       |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2025-05-06 16:15:29 +02:00
parent eb09c17a54
commit c389f28af0

View File

@ -817,7 +817,9 @@ set_font_authorizations(char **authorizations, int *authlen, void *client)
#endif
len = strlen(hnameptr) + 1;
result = malloc(len + sizeof(AUTHORIZATION_NAME) + 4);
result = calloc(1, len + sizeof(AUTHORIZATION_NAME) + 4);
if (!result)
return 0;
p = result;
*p++ = sizeof(AUTHORIZATION_NAME) >> 8;