]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: avoid "definitely lost" valgrind warnings
authorPádraig Brady <P@draigBrady.com>
Fri, 4 Sep 2015 13:38:06 +0000 (14:38 +0100)
committerPádraig Brady <P@draigBrady.com>
Fri, 4 Sep 2015 16:04:03 +0000 (17:04 +0100)
Since commit v8.23-19-g8defcee, main() will return,
rather than call exit(), this inducing "definitely lost"
warnings in valgrind's leak checker.  That precludes using
the following to flag memory leaks:

  valgrind --leak-check=full --error-exitcode=1 \
           --errors-for-leak-kinds=definite

* src/pr.c (main): In dev builds, explicitly free memory allocated.
* src/sort.c (main): Likewise.
* src/tail.c (main): Likewise.
* src/tsort.c (tsort): Likewise.

src/pr.c
src/sort.c
src/tail.c
src/tsort.c

index d79d84f186a97040784f92a174179ce0cbc2fe9b..887e1258425e711112e3467727bfa3e42d495117 100644 (file)
--- a/src/pr.c
+++ b/src/pr.c
@@ -1130,6 +1130,7 @@ main (int argc, char **argv)
     }
 
   cleanup ();
+  IF_LINT (free (file_names));
 
   if (have_read_stdin && fclose (stdin) == EOF)
     error (EXIT_FAILURE, errno, _("standard input"));
index 85fc38f73d2bc8c0ce6a8be14c1153dc4013532d..a7eda8325ac31235f07a9a94633591784642397f 100644 (file)
@@ -4742,6 +4742,8 @@ main (int argc, char **argv)
       sort (files, nfiles, outfile, nthreads);
     }
 
+  IF_LINT (free (files));
+
   if (have_read_stdin && fclose (stdin) == EOF)
     die (_("close failed"), "-");
 
index c062d403ff96481545dbbc742b4c02230f31ff77..f916d7460395f0cee52c592bc3d160ac94697e73 100644 (file)
@@ -2354,6 +2354,8 @@ main (int argc, char **argv)
       tail_forever (F, n_files, sleep_interval);
     }
 
+  IF_LINT (free (F));
+
   if (have_read_stdin && close (STDIN_FILENO) < 0)
     error (EXIT_FAILURE, errno, "-");
   return ok ? EXIT_SUCCESS : EXIT_FAILURE;
index d4be03d427fefaf4f4a3156de97c26f7d902ef03..0533451dad165bffe008350373e17587744e7bef 100644 (file)
@@ -528,6 +528,8 @@ tsort (const char *file)
         }
     }
 
+  IF_LINT (free (root));
+
   if (fclose (stdin) != 0)
     error (EXIT_FAILURE, errno, "%s",
            is_stdin ? _("standard input") : quote (file));