Cygwin: Zero out gmon header before use

Tools that process gmon.out files can be confused by gmon header fields
with garbage in them due to lack of initialization.  Repair that.
This commit is contained in:
Mark Geisert 2021-06-23 01:56:14 -07:00 committed by Jon Turney
parent a39ae40b86
commit 5c9c31c52b
No known key found for this signature in database
GPG Key ID: C7C86F0370285C81
1 changed files with 1 additions and 0 deletions

View File

@ -224,6 +224,7 @@ _mcleanup(void)
write(log, dbuf, len); write(log, dbuf, len);
#endif #endif
hdr = (struct gmonhdr *)&gmonhdr; hdr = (struct gmonhdr *)&gmonhdr;
bzero(hdr, sizeof *hdr);
hdr->lpc = p->lowpc; hdr->lpc = p->lowpc;
hdr->hpc = p->highpc; hdr->hpc = p->highpc;
hdr->ncnt = p->kcountsize + sizeof(gmonhdr); hdr->ncnt = p->kcountsize + sizeof(gmonhdr);