diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-11-04 10:10:34 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-11-04 13:01:43 -0700 |
commit | fa682decde0b4513f5ce6084df590107359158f5 (patch) | |
tree | bcb78e5c546d6f4b5918d977574cbe6ddd987210 /mkfontscale.c | |
parent | 05401f3c4e641c1e67d11187dfb943c7ec1708f4 (diff) |
doDirectory: add missing check for malloc() returning NULL
Resolves gcc analyzer warning:
mkfontscale.c: In function ‘doDirectory’:
mkfontscale.c:974:17: warning: use of possibly-NULL ‘s’ where non-null expected [CWE-690] [-Wanalyzer-possible-null-argument]
974 | memcpy(s, xlfd_name, l - 11);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'mkfontscale.c')
-rw-r--r-- | mkfontscale.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/mkfontscale.c b/mkfontscale.c index d692e3c..2b07c67 100644 --- a/mkfontscale.c +++ b/mkfontscale.c @@ -971,6 +971,10 @@ doDirectory(const char *dirname_given, int numEncodings, ListPtr encodingsToDo) char *s; s = malloc(l - 10); + if (s == NULL) { + fprintf(stderr, "Couldn't allocate xlfd name\n"); + exit(1); + } memcpy(s, xlfd_name, l - 11); s[l - 11] = '\0'; xlfd = listCons(s, xlfd); |