summaryrefslogtreecommitdiffstats
path: root/common.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-01-07 19:13:54 +0000
committerRoy Marples <roy@marples.name>2008-01-07 19:13:54 +0000
commitb32d2967bc9f6d01cf5c95fb0b92cf2e670db0d2 (patch)
tree5b2e729c12aedafb0a19f15b6ccbc23799b73edb /common.c
parentb5d0d901da7cd53ea7f2b3a21c4ef6cbb4ce69c0 (diff)
downloaddhcpcd-b32d2967bc9f6d01cf5c95fb0b92cf2e670db0d2.tar.xz
Avoid valgrind errors with getline.
Diffstat (limited to 'common.c')
-rw-r--r--common.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/common.c b/common.c
index 2330889f..84f05080 100644
--- a/common.c
+++ b/common.c
@@ -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);