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:
Andre Silva authored and Mitchell Horne committed 2026-11-05 09:55:07 -04:00
1 parent abd7dfa09a
commit a97914284c
1 file changed
+1 -1
+1 -1
View File
@@ -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;