From: Sami Kerola Date: Sat, 2 Apr 2011 16:11:08 +0000 (+0200) Subject: rev: memory leak fix X-Git-Tag: v2.20-rc1~389 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2226064c52af6ae5d5c8871056aede10a7d14b97;p=thirdparty%2Futil-linux.git 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 --- diff --git a/text-utils/rev.c b/text-utils/rev.c index 31004a0700..76a362030b 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);