diff options
author | maxim <maxim@FreeBSD.org> | 2008-01-12 20:37:06 +0000 |
---|---|---|
committer | maxim <maxim@FreeBSD.org> | 2008-01-12 20:37:06 +0000 |
commit | 147942350a8478fcc6299fcce1e5618cac264bf5 (patch) | |
tree | 2ec3f8261f023311ed8f8264a0c5b8b46af7e02b /usr.sbin | |
parent | dce4b2b9ef6c11f8ad78b174c957c834d1eba43a (diff) | |
download | FreeBSD-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')
-rw-r--r-- | usr.sbin/iostat/iostat.c | 6 |
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; |