From 2bcccc224c9cf7992bf6796b12287d4175485369 Mon Sep 17 00:00:00 2001 From: Ian Dowse Date: Sun, 20 Mar 2005 22:08:52 +0000 Subject: [PATCH] Don't skip the initialisation of tl->len when we hit an EOF immediately after allocating a new buffer. This bug caused `tail -r < /dev/null' to core dump when the `J' malloc option is set, and also affected any other input that was an exact multiple of 128k. --- usr.bin/tail/reverse.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/usr.bin/tail/reverse.c b/usr.bin/tail/reverse.c index ea2ed70df00..f0a52aa8bcc 100644 --- a/usr.bin/tail/reverse.c +++ b/usr.bin/tail/reverse.c @@ -234,9 +234,8 @@ r_buf(FILE *fp) * If no input data for this block and we tossed some data, * recover it. */ - if (!len) { - if (enomem) - enomem -= tl->len; + if (!len && enomem) { + enomem -= tl->len; tl = tl->prev; break; }