]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: always free a buffer, to avoid even semblance of a leak
authorJim Meyering <meyering@redhat.com>
Mon, 4 Jan 2010 15:49:30 +0000 (16:49 +0100)
committerJim Meyering <meyering@redhat.com>
Tue, 5 Jan 2010 08:08:03 +0000 (09:08 +0100)
* src/tac.c (main): Free the input buffer in most cases.

src/tac.c

index 465a089592032d8d20dc3ab8ebd153aa11df1af7..c7af6c11cb3e853a6529c23bdb8a7eb1a7fc57f7 100644 (file)
--- a/src/tac.c
+++ b/src/tac.c
@@ -633,6 +633,7 @@ main (int argc, char **argv)
   if (! (read_size < half_buffer_size && half_buffer_size < G_buffer_size))
     xalloc_die ();
   G_buffer = xmalloc (G_buffer_size);
+  void *buf = G_buffer;
   if (sentinel_length)
     {
       strcpy (G_buffer, separator);
@@ -661,6 +662,10 @@ main (int argc, char **argv)
   output ((char *) NULL, (char *) NULL);
 
   if (have_read_stdin && close (STDIN_FILENO) < 0)
-    error (EXIT_FAILURE, errno, "-");
+    {
+      error (0, errno, "-");
+      ok = false;
+    }
+  free (buf);
   exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
 }