diff options
author | Jim Meyering <meyering@redhat.com> | 2010-01-04 16:49:30 +0100 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2010-01-05 09:08:03 +0100 |
commit | be6c13e7e0abc46121c4250c82019179fd5e85c2 (patch) | |
tree | f1eae643569a850f76ad542cfacb35040007bfe9 /src | |
parent | dc0f5eb6a01b759c92478be7f21de3e685ebfbca (diff) | |
download | coreutils-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')
-rw-r--r-- | src/tac.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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); } |