aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
diff options
context:
space:
mode:
Diffstat (limited to 'toys/posix')
-rw-r--r--toys/posix/tail.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/toys/posix/tail.c b/toys/posix/tail.c
index e1048be7..aba53180 100644
--- a/toys/posix/tail.c
+++ b/toys/posix/tail.c
@@ -176,9 +176,13 @@ static void do_tail(int fd, char *name)
linepop = try[count] == '\n';
if (lines > 0) {
+ char c;
+
do {
+ c = *list->data;
if (!--(list->len)) free(dlist_pop(&list));
- } while (*(list->data++) != '\n');
+ else list->data++;
+ } while (c != '\n');
lines--;
}
}