diff options
| author | Roy Marples <roy@marples.name> | 2008-01-07 19:13:54 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2008-01-07 19:13:54 +0000 |
| commit | b32d2967bc9f6d01cf5c95fb0b92cf2e670db0d2 (patch) | |
| tree | 5b2e729c12aedafb0a19f15b6ccbc23799b73edb /common.c | |
| parent | b5d0d901da7cd53ea7f2b3a21c4ef6cbb4ce69c0 (diff) | |
| download | dhcpcd-b32d2967bc9f6d01cf5c95fb0b92cf2e670db0d2.tar.xz | |
Avoid valgrind errors with getline.
Diffstat (limited to 'common.c')
| -rw-r--r-- | common.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -57,12 +57,13 @@ char *getline (FILE *fp) 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); |
