summaryrefslogtreecommitdiff
path: root/src/tac.c
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2010-01-04 16:49:30 +0100
committerJim Meyering <meyering@redhat.com>2010-01-05 09:08:03 +0100
commitbe6c13e7e0abc46121c4250c82019179fd5e85c2 (patch)
treef1eae643569a850f76ad542cfacb35040007bfe9 /src/tac.c
parentdc0f5eb6a01b759c92478be7f21de3e685ebfbca (diff)
downloadcoreutils-be6c13e7e0abc46121c4250c82019179fd5e85c2.tar.xz
maint: always free a buffer, to avoid even semblance of a leak
* src/tac.c (main): Free the input buffer in most cases.
Diffstat (limited to 'src/tac.c')
-rw-r--r--src/tac.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/tac.c b/src/tac.c
index 465a08959..c7af6c11c 100644
--- 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);
}