diff options
author | Maxim Konovalov <maxim@FreeBSD.org> | 2008-01-12 20:37:06 +0000 |
---|---|---|
committer | Maxim Konovalov <maxim@FreeBSD.org> | 2008-01-12 20:37:06 +0000 |
commit | 38992545b716315a549ee15025956fac1e1bf139 (patch) | |
tree | 2ec3f8261f023311ed8f8264a0c5b8b46af7e02b /usr.sbin | |
parent | 9b74c87f1f3107a3760cd18cdf2ee861e6aeaab0 (diff) | |
download | src-38992545b716315a549ee15025956fac1e1bf139.tar.gz src-38992545b716315a549ee15025956fac1e1bf139.zip |
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
Notes
Notes:
svn path=/head/; revision=175250
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 e54e29c70ac7..2ed804952e46 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; |