]> granicus.if.org Git - file/commitdiff
Don't forget to NUL terminate if the last line did not have delim.
authorChristos Zoulas <christos@zoulas.com>
Mon, 15 Sep 2014 23:24:01 +0000 (23:24 +0000)
committerChristos Zoulas <christos@zoulas.com>
Mon, 15 Sep 2014 23:24:01 +0000 (23:24 +0000)
From: Hubert Garavel

src/getline.c

index 99cd15075caa5192f498f53bd65c592f42b21706..de44762827339d7946881e50a65b77c88fe9ae33 100644 (file)
@@ -52,6 +52,7 @@ getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp)
        for (ptr = *buf, eptr = *buf + *bufsiz;;) {
                int c = fgetc(fp);
                if (c == -1) {
+                       *ptr = '\0';
                        if (feof(fp))
                                return ptr == *buf ? -1 : ptr - *buf;
                        else