From 6b1ce4b2a1eb356541bbc5ed661344b30f7bab85 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Tue, 18 Sep 2007 13:37:46 +0200 Subject: intotail.c: Check for n_units == 0 before calling tail_pipe_*() --- inotail.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/inotail.c b/inotail.c index cd96ec1..c455fd0 100644 --- a/inotail.c +++ b/inotail.c @@ -247,9 +247,6 @@ static ssize_t tail_pipe_lines(struct file_struct *f, unsigned long n_lines) unsigned long total_lines = 0; const char *p; - if (n_lines == 0) - return 0; - first = last = emalloc(sizeof(struct line_buf)); first->n_bytes = first->n_lines = 0; first->next = NULL; @@ -352,9 +349,6 @@ static ssize_t tail_pipe_bytes(struct file_struct *f, unsigned long n_bytes) unsigned long total_bytes = 0; unsigned long i = 0; /* Index into buffer */ - if (n_bytes == 0) - return 0; - first = last = emalloc(sizeof(struct char_buf)); first->n_bytes = 0; first->next = NULL; @@ -461,6 +455,9 @@ static int tail_file(struct file_struct *f, unsigned long n_units, char mode, ch if (verbose) write_header(f->name); + if (n_units == 0) + return 0; + if (mode == M_LINES) return tail_pipe_lines(f, n_units); else -- cgit v1.2.3-54-g00ecf