diff -Naurp pcp-4.3.2.wip/src/pcp/atop/atop.c pcp-4.3.2/src/pcp/atop/atop.c
--- pcp-4.3.2.wip/src/pcp/atop/atop.c 2020-02-17 17:31:31.697197181 +1100
+++ pcp-4.3.2/src/pcp/atop/atop.c 2020-02-17 17:32:10.437750572 +1100
@@ -631,14 +631,12 @@ engine(void)
*/
if (nprocexit > 0)
{
- curpexit = malloc(nprocexit * sizeof(struct tstat));
+ curpexit = calloc(nprocexit, sizeof(struct tstat));
ptrverify(curpexit,
"Malloc failed for %lu exited processes\n",
nprocexit);
- memset(curpexit, 0, nprocexit * sizeof(struct tstat));
-
nprocexit = acctphotoproc(curpexit, nprocexit);
/*
diff -Naurp pcp-4.3.2.wip/src/pcp/atop/deviate.c pcp-4.3.2/src/pcp/atop/deviate.c
--- pcp-4.3.2.wip/src/pcp/atop/deviate.c 2019-03-08 08:26:34.000000000 +1100
+++ pcp-4.3.2/src/pcp/atop/deviate.c 2020-02-17 17:32:10.437750572 +1100
@@ -84,7 +84,7 @@ deviattask(struct tstat *curtpres, un
** create list for the sample deviations of all tasks
*/
devtstat->ntaskall = ntaskpres + nprocexit;
- devtstat->taskall = malloc(devtstat->ntaskall * sizeof(struct tstat));
+ devtstat->taskall = calloc(devtstat->ntaskall, sizeof(struct tstat));
ptrverify(devtstat->taskall, "Malloc failed for %lu deviated tasks\n",
devtstat->ntaskall);
@@ -371,9 +371,9 @@ deviattask(struct tstat *curtpres, un
/*
** create and fill other pointer lists
*/
- devtstat->procall = malloc(devtstat->nprocall *
+ devtstat->procall = calloc(devtstat->nprocall,
sizeof(struct tstat *));
- devtstat->procactive = malloc(devtstat->nprocactive *
+ devtstat->procactive = calloc(devtstat->nprocactive,
sizeof(struct tstat *));
ptrverify(devtstat->procall, "Malloc failed for %d processes\n",
diff -Naurp pcp-4.3.2.wip/src/pcp/atop/photoproc.c pcp-4.3.2/src/pcp/atop/photoproc.c
--- pcp-4.3.2.wip/src/pcp/atop/photoproc.c 2019-01-24 10:23:34.000000000 +1100
+++ pcp-4.3.2/src/pcp/atop/photoproc.c 2020-02-17 17:32:10.438750561 +1100
@@ -166,8 +166,10 @@ photoproc(struct tstat **tasks, unsigned
fprintf(stderr, "%s: done %lu processes\n", pmGetProgname(), count);
pmFreeResult(result);
- free(insts);
- free(pids);
+ if (count > 0) {
+ free(insts);
+ free(pids);
+ }
return count;
}
diff -Naurp pcp-4.3.2.wip/src/pcp/atop/showlinux.c pcp-4.3.2/src/pcp/atop/showlinux.c
--- pcp-4.3.2.wip/src/pcp/atop/showlinux.c 2019-01-24 10:24:56.000000000 +1100
+++ pcp-4.3.2/src/pcp/atop/showlinux.c 2020-02-17 17:32:10.438750561 +1100
@@ -654,19 +654,22 @@ totalcap(struct syscap *psc, struct ssta
struct tstat *curstat = *(proclist+i);
count_t nett_wsz;
- psc->availnet += curstat->net.tcpssz;
- psc->availnet += curstat->net.tcprsz;
- psc->availnet += curstat->net.udpssz;
- psc->availnet += curstat->net.udprsz;
-
- if (curstat->dsk.wsz > curstat->dsk.cwsz)
- nett_wsz = curstat->dsk.wsz -
- curstat->dsk.cwsz;
- else
- nett_wsz = 0;
+ if (curstat)
+ {
+ psc->availnet += curstat->net.tcpssz;
+ psc->availnet += curstat->net.tcprsz;
+ psc->availnet += curstat->net.udpssz;
+ psc->availnet += curstat->net.udprsz;
+
+ if (curstat->dsk.wsz > curstat->dsk.cwsz)
+ nett_wsz = curstat->dsk.wsz -
+ curstat->dsk.cwsz;
+ else
+ nett_wsz = 0;
- psc->availdsk += curstat->dsk.rsz;
- psc->availdsk += nett_wsz;
+ psc->availdsk += curstat->dsk.rsz;
+ psc->availdsk += nett_wsz;
+ }
}
for (psc->availgpumem=i=0; i < sstat->gpu.nrgpus; i++)
@@ -985,8 +988,11 @@ pricumproc(struct sstat *sstat, struct d
{
struct tstat *curstat = *(devtstat->procactive+i);
- extra.totut += curstat->cpu.utime;
- extra.totst += curstat->cpu.stime;
+ if (curstat)
+ {
+ extra.totut += curstat->cpu.utime;
+ extra.totst += curstat->cpu.stime;
+ }
}
extra.nproc = devtstat->nprocall;