diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2007-09-18 13:37:46 +0200 |
---|---|---|
committer | Tobias Klauser <tklauser@xenon.tklauser.home> | 2007-09-18 13:37:46 +0200 |
commit | 6b1ce4b2a1eb356541bbc5ed661344b30f7bab85 (patch) | |
tree | 160690f04fd3031b34e798e418a7751eab94800b | |
parent | 8787c5e9f422ae6a9d3e3f5445301f753c3fe02d (diff) |
intotail.c: Check for n_units == 0 before calling tail_pipe_*()
-rw-r--r-- | inotail.c | 9 |
1 files changed, 3 insertions, 6 deletions
@@ -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 |