aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-01-07 19:12:58 +0000
committerRoy Marples <roy@marples.name>2008-01-07 19:12:58 +0000
commit2e35d2a73c8b44b5f719c9fd62b892f09297e53c (patch)
tree6dd70ec4d58a91d5b6bf263f41e474e6ae8e50f4 /src
parent81b8e5450e2aee2a35a1913e3e051e4c4cd22ece (diff)
Avoid valgrind errors with getline.
Diffstat (limited to 'src')
-rw-r--r--src/librc/librc-misc.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/librc/librc-misc.c b/src/librc/librc-misc.c
index f77b2f78..4a16e9fe 100644
--- a/src/librc/librc-misc.c
+++ b/src/librc/librc-misc.c
@@ -119,12 +119,13 @@ char *rc_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);