summaryrefslogtreecommitdiffstats
path: root/sys-utils/dmesg.c
diff options
context:
space:
mode:
authorDavidlohr Bueso2010-07-30 17:43:36 +0200
committerKarel Zak2010-08-04 11:46:38 +0200
commit219da9223d14aa21e4feb4fe850eb4c1691c98d8 (patch)
tree4d4992a01ffcbdf58eb7cf43e9e6ea83b4f7bbb2 /sys-utils/dmesg.c
parentmount: get most recently mounted fs from /etc/mtab. (diff)
downloadkernel-qcow2-util-linux-219da9223d14aa21e4feb4fe850eb4c1691c98d8.tar.gz
kernel-qcow2-util-linux-219da9223d14aa21e4feb4fe850eb4c1691c98d8.tar.xz
kernel-qcow2-util-linux-219da9223d14aa21e4feb4fe850eb4c1691c98d8.zip
dmesg: fix memory leak in dmesg(1).
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Diffstat (limited to 'sys-utils/dmesg.c')
-rw-r--r--sys-utils/dmesg.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c
index fd184aaf4..f1a7dcb7c 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;
}