summaryrefslogtreecommitdiff
path: root/src/split.c
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2012-08-02 19:31:36 +0200
committerJim Meyering <meyering@redhat.com>2012-08-04 11:32:01 +0200
commit4abec7ef9a3e162098b6b4c1e19a8235023130d4 (patch)
treeb76566ad8054ad43f5570648b270e8b3447ba1b6 /src/split.c
parente11a2cf3198bcec9a5e10205bf3ebe66dc7edc59 (diff)
downloadcoreutils-4abec7ef9a3e162098b6b4c1e19a8235023130d4.tar.xz
split: plug nominal leaks
* src/split.c (lines_rr) [IF_LINT]: Plug a harmless leak. (main) [IF_LINT]: Free a usually-small (~70KB) buffer just before exit, mainly to take this off the radar of leak-detecting tools. Improved-by: Pádraig Brady.
Diffstat (limited to 'src/split.c')
-rw-r--r--src/split.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/split.c b/src/split.c
index 7ba743cb0..d1037eca7 100644
--- a/src/split.c
+++ b/src/split.c
@@ -1044,6 +1044,7 @@ no_filters:
files[i_file].ofd = OFD_APPEND;
}
}
+ IF_LINT (free (files));
}
#define FAIL_ONLY_ONE_WAY() \
@@ -1075,7 +1076,6 @@ main (int argc, char **argv)
{
enum Split_type split_type = type_undef;
size_t in_blk_size = 0; /* optimal block size of input file device */
- char *buf; /* file i/o buffer */
size_t page_size = getpagesize ();
uintmax_t k_units = 0;
uintmax_t n_units;
@@ -1382,7 +1382,8 @@ main (int argc, char **argv)
file_size = MAX (file_size, n_units);
}
- buf = ptr_align (xmalloc (in_blk_size + 1 + page_size - 1), page_size);
+ void *b = xmalloc (in_blk_size + 1 + page_size - 1);
+ char *buf = ptr_align (b, page_size);
/* When filtering, closure of one pipe must not terminate the process,
as there may still be other streams expecting input from us. */
@@ -1432,6 +1433,8 @@ main (int argc, char **argv)
abort ();
}
+ IF_LINT (free (b));
+
if (close (STDIN_FILENO) != 0)
error (EXIT_FAILURE, errno, "%s", infile);
closeout (NULL, output_desc, filter_pid, outfile);