summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2007-09-18 13:37:46 +0200
committerTobias Klauser <tklauser@xenon.tklauser.home>2007-09-18 13:37:46 +0200
commit6b1ce4b2a1eb356541bbc5ed661344b30f7bab85 (patch)
tree160690f04fd3031b34e798e418a7751eab94800b
parent8787c5e9f422ae6a9d3e3f5445301f753c3fe02d (diff)
intotail.c: Check for n_units == 0 before calling tail_pipe_*()
-rw-r--r--inotail.c9
1 files 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