add is_init check to malloc_info

This commit is contained in:
Daniel Micay 2020-09-17 16:07:10 -04:00
parent 9fb2791af2
commit 50e0f1334c

View File

@ -1800,6 +1800,8 @@ EXPORT int h_malloc_info(int options, UNUSED FILE *fp) {
#if CONFIG_STATS #if CONFIG_STATS
fputs("<malloc version=\"hardened_malloc-1\">", fp); fputs("<malloc version=\"hardened_malloc-1\">", fp);
if (is_init()) {
for (unsigned arena = 0; arena < N_ARENA; arena++) { for (unsigned arena = 0; arena < N_ARENA; arena++) {
fprintf(fp, "<heap nr=\"%u\">", arena); fprintf(fp, "<heap nr=\"%u\">", arena);
@ -1841,6 +1843,7 @@ EXPORT int h_malloc_info(int options, UNUSED FILE *fp) {
fprintf(fp, "<heap nr=\"%u\">", N_ARENA); fprintf(fp, "<heap nr=\"%u\">", N_ARENA);
fprintf(fp, "<allocated_large>%zu</allocated_large>", region_allocated); fprintf(fp, "<allocated_large>%zu</allocated_large>", region_allocated);
fputs("</heap>", fp); fputs("</heap>", fp);
}
fputs("</malloc>", fp); fputs("</malloc>", fp);