mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-19 03:33:43 +03:00
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.
This commit is contained in:
1 parent
a4b640549d
commit
5bbdcd2a02
1 file changed
+8
-3
+8
-3
@@ -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"), "-");
|
||||
|
||||
Reference in new issue
Block a user