Mercurial > hg > dhcpcd
changeset 254:fc6bf106cccb draft
Avoid valgrind errors with getline.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Mon, 07 Jan 2008 19:13:54 +0000 |
| parents | e64359f8a191 |
| children | fff49a02f6d5 |
| files | common.c |
| diffstat | 1 files changed, 2 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/common.c Mon Jan 07 18:14:51 2008 +0000 +++ b/common.c Mon Jan 07 19:13:54 2008 +0000 @@ -57,12 +57,13 @@ len += BUFSIZ; line = xrealloc (line, sizeof (char) * len); p = line + last; + memset (p, 0, BUFSIZ); fgets (p, BUFSIZ, fp); last += strlen (p); } while (! feof (fp) && line[last - 1] != '\n'); /* Trim the trailing newline */ - if (line[--last] == '\n') + if (*line && line[--last] == '\n') line[last] = '\0'; return (line);
