summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2022-08-14 10:10:23 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2022-08-14 10:10:23 -0700
commit88262a274bdd850e14cc27dd3d421182bbc157d5 (patch)
tree561f0d6c803cf1ea57c542ffe57e3fe70ba573a1
parent0c55e2eabe6755b88de9835da8185a52b7712847 (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.c2
-rw-r--r--smproxy.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/save.c b/save.c
index 738ada9..db5ca1e 100644
--- a/save.c
+++ b/save.c
@@ -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;
diff --git a/smproxy.c b/smproxy.c
index c29c050..461b14b 100644
--- a/smproxy.c
+++ b/smproxy.c
@@ -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)
{