aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/tail
diff options
context:
space:
mode:
authorAlan Somers <asomers@FreeBSD.org>2017-01-04 23:22:34 +0000
committerAlan Somers <asomers@FreeBSD.org>2017-01-04 23:22:34 +0000
commit2277edc8a619157a2bea98a4b703f61fde6b17f5 (patch)
tree6484c77ce58b6182023d51c165647e0fb061a26e /usr.bin/tail
parent1e0c121f3ac0791243f7766babd313a8aea48703 (diff)
downloadsrc-2277edc8a619157a2bea98a4b703f61fde6b17f5.tar.gz
src-2277edc8a619157a2bea98a4b703f61fde6b17f5.zip
Notes
Diffstat (limited to 'usr.bin/tail')
-rw-r--r--usr.bin/tail/reverse.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/usr.bin/tail/reverse.c b/usr.bin/tail/reverse.c
index 511f88c02278..87269051ed68 100644
--- a/usr.bin/tail/reverse.c
+++ b/usr.bin/tail/reverse.c
@@ -117,6 +117,7 @@ r_reg(FILE *fp, const char *fn, enum STYLE style, off_t off, struct stat *sbp)
map.start = NULL;
map.mapoff = map.maxoff = size;
map.fd = fileno(fp);
+ map.maplen = 0;
/*
* Last char is special, ignore whether newline or not. Note that
@@ -205,7 +206,13 @@ r_buf(FILE *fp, const char *fn)
(tl->l = malloc(BSZ)) == NULL) {
if (!mark)
err(1, "malloc");
- tl = enomem ? tl->next : mark;
+ if (enomem)
+ tl = tl->next;
+ else {
+ if (tl)
+ free(tl);
+ tl = mark;
+ }
enomem += tl->len;
} else if (mark) {
tl->next = mark;