summaryrefslogtreecommitdiffstats
path: root/usr.bin/vmstat/vmstat.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/vmstat/vmstat.c')
-rw-r--r--usr.bin/vmstat/vmstat.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c
index 6217964..ea16ee2 100644
--- a/usr.bin/vmstat/vmstat.c
+++ b/usr.bin/vmstat/vmstat.c
@@ -916,12 +916,12 @@ dosysctl(const char *name)
for (buf = NULL, bufsize = 1024; ; bufsize *= 2) {
if ((buf = realloc(buf, bufsize)) == NULL)
err(1, "realloc()");
- if (mysysctl(name, buf, &bufsize, 0, NULL) == 0)
+ bufsize--; /* Leave space for the kern.malloc fixup. */
+ if (mysysctl(name, buf, &bufsize, NULL, 0) == 0)
break;
- bufsize *= 2;
}
- buf[bufsize] = '\0'; /* play it safe */
- (void)printf("%s\n\n", buf);
+ buf[bufsize] = '\0'; /* Fix up kern.malloc not returning a string. */
+ (void)printf("%s", buf);
free(buf);
}
OpenPOWER on IntegriCloud