]> 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>
Fri, 18 Mar 2011 08:52:07 +0000 (09:52 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
text-utils/tailf.c

index 0b99a1ae69d0f2b6ba733fc316751f0d5c9b58bf..fbe81c89de982b6ee3e7dc197d80e6a73978b6a7 100644 (file)
@@ -60,7 +60,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) {