summaryrefslogtreecommitdiffstats
path: root/usr.sbin/iostat
diff options
context:
space:
mode:
authormaxim <maxim@FreeBSD.org>2008-01-12 20:37:06 +0000
committermaxim <maxim@FreeBSD.org>2008-01-12 20:37:06 +0000
commit147942350a8478fcc6299fcce1e5618cac264bf5 (patch)
tree2ec3f8261f023311ed8f8264a0c5b8b46af7e02b /usr.sbin/iostat
parentdce4b2b9ef6c11f8ad78b174c957c834d1eba43a (diff)
downloadFreeBSD-src-147942350a8478fcc6299fcce1e5618cac264bf5.zip
FreeBSD-src-147942350a8478fcc6299fcce1e5618cac264bf5.tar.gz
o Plug a memory leak: do not forget to free asprintf(3) allocated
memory. PR: bin/119608 Submitted by: peter.schuller MFC after: 1 week
Diffstat (limited to 'usr.sbin/iostat')
-rw-r--r--usr.sbin/iostat/iostat.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.sbin/iostat/iostat.c b/usr.sbin/iostat/iostat.c
index e54e29c..2ed8049 100644
--- a/usr.sbin/iostat/iostat.c
+++ b/usr.sbin/iostat/iostat.c
@@ -735,9 +735,10 @@ devstats(int perf_select, long double etime, int havelast)
}
if (xflag > 0) {
- asprintf(&devname, "%s%d",
+ if (asprintf(&devname, "%s%d",
cur.dinfo->devices[di].device_name,
- cur.dinfo->devices[di].unit_number);
+ cur.dinfo->devices[di].unit_number) == 1)
+ errx(1, "asprintf() failed (out of memory?)");
/*
* If zflag is set, skip any devices with zero I/O.
*/
@@ -781,6 +782,7 @@ devstats(int perf_select, long double etime, int havelast)
}
printf("\n");
}
+ free(devname);
} else if (oflag > 0) {
int msdig = (ms_per_transaction < 100.0) ? 1 : 0;
OpenPOWER on IntegriCloud