bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FYI: tiny leak in sort


From: Jim Meyering
Subject: FYI: tiny leak in sort
Date: Mon, 13 Nov 2006 15:08:39 +0100

Running "sort < /dev/null" would leak a few bytes.
It's not a real problem, but worth fixing just to avoid the distraction
when you're trying to ensure there are no leaks in all 90+ tools.

        * src/sort.c (main): Plug a tiny memory leak.
        Move declaration of local "minus" down to be nearer point of use.

diff --git a/src/sort.c b/src/sort.c
index e08d058..56a0651 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -2292,7 +2292,7 @@ main (int argc, char **argv)
   size_t nfiles = 0;
   bool posixly_correct = (getenv ("POSIXLY_CORRECT") != NULL);
   bool obsolete_usage = (posix2_version () < 200112);
-  char *minus = "-", **files;
+  char **files;
   char const *outfile = NULL;

   initialize_main (&argc, &argv);
@@ -2657,7 +2657,9 @@ main (int argc, char **argv)

   if (nfiles == 0)
     {
+      static char *minus = "-";
       nfiles = 1;
+      free (files);
       files = &minus;
     }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]