From: Christos Zoulas Date: Mon, 15 Sep 2014 23:24:01 +0000 (+0000) Subject: Don't forget to NUL terminate if the last line did not have delim. X-Git-Tag: FILE5_20~12 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=41328b56a34bc25720eae4a389c6908e9844532d;p=file Don't forget to NUL terminate if the last line did not have delim. From: Hubert Garavel --- diff --git a/src/getline.c b/src/getline.c index 99cd1507..de447628 100644 --- a/src/getline.c +++ b/src/getline.c @@ -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