diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-08-14 10:10:23 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-08-14 10:10:23 -0700 |
commit | 88262a274bdd850e14cc27dd3d421182bbc157d5 (patch) | |
tree | 561f0d6c803cf1ea57c542ffe57e3fe70ba573a1 | |
parent | 0c55e2eabe6755b88de9835da8185a52b7712847 (diff) |
Use calloc instead of malloc to allocate arrays
Most important in ReadProxyFileEntry, if we goto give_up before we
finish initializing the array, makes sure we don't try to free
uninitialized pointers during cleanup pass.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | save.c | 2 | ||||
-rw-r--r-- | smproxy.c | 4 |
2 files changed, 3 insertions, 3 deletions
@@ -263,7 +263,7 @@ ReadProxyFileEntry(FILE *proxyFile, ProxyFileEntry **pentry) entry->wm_command = NULL; else { - entry->wm_command = malloc (entry->wm_command_count * sizeof (char *)); + entry->wm_command = calloc (entry->wm_command_count, sizeof (char *)); if (!entry->wm_command) goto give_up; @@ -290,7 +290,7 @@ FinishSaveYourself(WinInfo *winInfo, Bool has_WM_SAVEYOURSELF) prop1.type = SmLISTofARRAY8; prop1.num_vals = winInfo->wm_command_count; - prop1.vals = malloc (winInfo->wm_command_count * sizeof (SmPropValue)); + prop1.vals = calloc (winInfo->wm_command_count, sizeof (SmPropValue)); if (!prop1.vals) { @@ -931,7 +931,7 @@ ProxySaveYourselfPhase2CB(SmcConn smcConn, SmPointer clientData) prop1.name = SmRestartCommand; prop1.type = SmLISTofARRAY8; - prop1.vals = malloc ((Argc + 4) * sizeof (SmPropValue)); + prop1.vals = calloc ((Argc + 4), sizeof (SmPropValue)); if (!prop1.vals) { |