aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/random
diff options
context:
space:
mode:
authorConrad Meyer <cem@FreeBSD.org>2016-05-11 22:04:28 +0000
committerConrad Meyer <cem@FreeBSD.org>2016-05-11 22:04:28 +0000
commit7bfdbca59613182ce7f7a5e1082fc1e76f612783 (patch)
treef38d90af23cd10217694b63ab93eb74b0a14f815 /usr.bin/random
parent699b3c872201a094a363a1f8e1a5ad3820d8c7e2 (diff)
Notes
Diffstat (limited to 'usr.bin/random')
-rw-r--r--usr.bin/random/randomize_fd.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/usr.bin/random/randomize_fd.c b/usr.bin/random/randomize_fd.c
index f66b9654d281..622bfc087519 100644
--- a/usr.bin/random/randomize_fd.c
+++ b/usr.bin/random/randomize_fd.c
@@ -174,7 +174,7 @@ randomize_fd(int fd, int type, int unique, double denom)
if ((type == RANDOM_TYPE_LINES && buf[i] == '\n') ||
(type == RANDOM_TYPE_WORDS && isspace(buf[i])) ||
(eof && i == buflen - 1)) {
- make_token:
+make_token:
if (numnode == RANDOM_MAX_PLUS1) {
errno = EFBIG;
err(1, "too many delimiters");
@@ -199,7 +199,10 @@ randomize_fd(int fd, int type, int unique, double denom)
}
}
- (void)close(fd);
+ if (fd >= 0) {
+ (void)close(fd);
+ fd = -1;
+ }
/* Necessary evil to compensate for files that don't end with a newline */
if (bufc != i) {