>From 535e106d22457435c8ef2773e0499b7cff2f9b19 Mon Sep 17 00:00:00 2001 From: Davidlohr Bueso <dave@xxxxxxx> Date: Fri, 30 Jul 2010 11:43:36 -0400 Subject: [PATCH] dmesg: Fix memory leak in dmesg(1). Signed-off-by: Davidlohr Bueso <dave@xxxxxxx> --- 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 fd184aa..f1a7dcb 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; } -- 1.7.0.4 -- To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html