mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-11-07 04:36:52 -10:00
pmc(8): zero-initialize the event descriptor in stat mode
cmd_pmc_stat allocated the event descriptor with malloc and then set only some of its fields, so the rest held whatever was on the heap. Use calloc() instead. Reviewed by: mhorne MFC after: 3 days Sponsored by: AMD Signed-off-by: Andre Silva <[email protected]> Differential Revision: https://reviews.freebsd.org/D59364
This commit is contained in:
1 parent
abd7dfa09a
commit
a97914284c
1 file changed
+1
-1
@@ -204,7 +204,7 @@ pmc_stat_setup_stat(int system_mode, const char *arg)
|
||||
pmc_args.pa_logfd = pmcstat_open_log(pmc_args.pa_outputpath,
|
||||
PMCSTAT_OPEN_FOR_WRITE);
|
||||
for (i = 0; i < STAT_MODE_NPMCS; i++) {
|
||||
if ((ev = malloc(sizeof(*ev))) == NULL)
|
||||
if ((ev = calloc(1, sizeof(*ev))) == NULL)
|
||||
errx(EX_SOFTWARE, "ERROR: Out of memory.");
|
||||
if (system_mode)
|
||||
ev->ev_mode = PMC_MODE_SC;
|
||||
|
||||
Reference in new issue
Block a user