diff options
author | Pádraig Brady <P@draigBrady.com> | 2015-09-08 12:53:11 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2015-09-08 12:56:04 +0100 |
commit | 5bbdcd2a02d9686edb788c46fc953192acdc6796 (patch) | |
tree | e70e1abae7e1d45dca18219085078a5061ff50e1 | |
parent | a4b640549df3216282f9d9924901b1521c3e2d69 (diff) | |
download | coreutils-5bbdcd2a02d9686edb788c46fc953192acdc6796.tar.xz |
maint: fix heap manipulations in previous commit
* src/sort.c (main): Ensure we don't free() and invalid
pointer when reading implicit stdin. Also avoid
"definitely lost" valgrind warnings in the --files0-from case.
-rw-r--r-- | src/sort.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/sort.c b/src/sort.c index a7eda8325..7ce059282 100644 --- a/src/sort.c +++ b/src/sort.c @@ -4681,10 +4681,10 @@ main (int argc, char **argv) if (nfiles == 0) { - static char *minus = (char *) "-"; nfiles = 1; free (files); - files = − + files = xmalloc (sizeof *files); + *files = (char *) "-"; } /* Need to re-check that we meet the minimum requirement for memory @@ -4742,7 +4742,12 @@ main (int argc, char **argv) sort (files, nfiles, outfile, nthreads); } - IF_LINT (free (files)); +#ifdef lint + if (files_from) + readtokens0_free (&tok); + else + free (files); +#endif if (have_read_stdin && fclose (stdin) == EOF) die (_("close failed"), "-"); |