diff options
author | Davidlohr Bueso <dave@gnu.org> | 2010-07-30 11:43:36 -0400 |
---|---|---|
committer | Karel Zak <kzak@redhat.com> | 2010-08-04 11:46:38 +0200 |
commit | 219da9223d14aa21e4feb4fe850eb4c1691c98d8 (patch) | |
tree | 4d4992a01ffcbdf58eb7cf43e9e6ea83b4f7bbb2 /sys-utils | |
parent | 5d79666f8f7563ed9904a7ce2087f430ee2702b6 (diff) | |
download | util-linux-old-219da9223d14aa21e4feb4fe850eb4c1691c98d8.tar.gz |
dmesg: fix memory leak in dmesg(1).
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Diffstat (limited to 'sys-utils')
-rw-r--r-- | sys-utils/dmesg.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c index fd184aaf..f1a7dcb7 100644 --- a/sys-utils/dmesg.c +++ b/sys-utils/dmesg.c @@ -111,12 +111,12 @@ main(int argc, char *argv[]) { if (bufsize) { sz = bufsize + 8; - buf = (char *) malloc(sz); + buf = (char *) malloc(sz * sizeof(char)); n = klogctl(cmd, buf, sz); } else { sz = 16392; while (1) { - buf = (char *) malloc(sz); + buf = (char *) malloc(sz * sizeof(char)); n = klogctl(3, buf, sz); /* read only */ if (n != sz || sz > (1<<28)) break; @@ -147,5 +147,6 @@ main(int argc, char *argv[]) { } if (lastc != '\n') putchar('\n'); + free(buf); return 0; } |