]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tailf: support --lines 0
authorKarel Zak <kzak@redhat.com>
Fri, 18 Mar 2011 08:52:07 +0000 (09:52 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 19 Apr 2011 11:09:52 +0000 (13:09 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
text-utils/tailf.c

index fa228433c1efe76742f76f566953499b88a0a92f..d13569212e89fc75b337b5763a72d03e7b9e17d2 100644 (file)
@@ -58,7 +58,7 @@ tailf(const char *filename, int lines)
        if (!(str = fopen(filename, "r")))
                err(EXIT_FAILURE, _("cannot open \"%s\" for read"), filename);
 
-       buf = xmalloc(lines * BUFSIZ);
+       buf = xmalloc((lines ? lines : 1) * BUFSIZ);
        p = buf;
        while (fgets(p, BUFSIZ, str)) {
                if (++tail >= lines) {