From 2226064c52af6ae5d5c8871056aede10a7d14b97 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 2 Apr 2011 18:11:08 +0200 Subject: rev: memory leak fix Moving the malloc out of loop will make leak to disappear, and the command might run few jiffie quicker when there are 1+N arguments. Signed-off-by: Sami Kerola --- text-utils/rev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'text-utils') diff --git a/text-utils/rev.c b/text-utils/rev.c index 31004a070..76a362030 100644 --- a/text-utils/rev.c +++ b/text-utils/rev.c @@ -107,6 +107,8 @@ int main(int argc, char *argv[]) argc -= optind; argv += optind; + buf = xmalloc(bufsiz * sizeof(wchar_t)); + do { if (*argv) { if ((fp = fopen(*argv, "r")) == NULL) { @@ -118,8 +120,6 @@ int main(int argc, char *argv[]) filename = *argv++; } - buf = xmalloc(bufsiz * sizeof(wchar_t)); - while (fgetws(buf, bufsiz, fp)) { len = wcslen(buf); -- cgit v1.2.3-55-g7522