diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-04-30 11:59:31 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-04-30 12:02:31 -0700 |
commit | 0f46b67b45ef40854ad7924e836134bf3f920e09 (patch) | |
tree | 7d33099b885fdbe990c59ed4fb2a1f010dee4a03 | |
parent | 3544fa9ec2e17e481785382317ef93ec2ac32ddf (diff) |
chooser: avoid free of uninitialized pointer in allocation failure cleanup
Resolves issue found by Oracle Parfait static analyzer:
Error: Uninitialised memory
Uninitialised memory [uninitialised-mem] (CWE 456):
Possible access to uninitialised memory referenced by 'new->fullname'
Memory 'new->fullname' accessed at byte offset '8'
at line 357 of app/xdm/chooser/chooser.c in function 'AddHostname'.
Write does not overlap at line 355
new allocated at line 329
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | chooser/chooser.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/chooser/chooser.c b/chooser/chooser.c index 4ccff56..e147302 100644 --- a/chooser/chooser.c +++ b/chooser/chooser.c @@ -326,7 +326,7 @@ AddHostname (ARRAY8Ptr hostname, ARRAY8Ptr status, struct sockaddr *addr, int wi } if (!*names) { - new = malloc (sizeof (HostName)); + new = calloc (1, sizeof (HostName)); if (!new) return 0; if (hostname->length) @@ -354,7 +354,6 @@ AddHostname (ARRAY8Ptr hostname, ARRAY8Ptr status, struct sockaddr *addr, int wi } if (!XdmcpAllocARRAY8 (&new->hostaddr, hostAddr.length)) { - free (new->fullname); free (new); return 0; } |