From: Jim Meyering Date: Mon, 4 Jan 2010 15:49:30 +0000 (+0100) Subject: maint: always free a buffer, to avoid even semblance of a leak X-Git-Tag: v8.3~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=be6c13e7;p=thirdparty%2Fcoreutils.git maint: always free a buffer, to avoid even semblance of a leak * src/tac.c (main): Free the input buffer in most cases. --- diff --git a/src/tac.c b/src/tac.c index 465a089592..c7af6c11cb 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); }