aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-01-07 14:59:17 +0000
committerRoy Marples <roy@marples.name>2008-01-07 14:59:17 +0000
commitfa898af7916ca05235bbd086a938952952d525ae (patch)
tree56ad57bbd7253424631ed85c6d2fc6a0b8597fac
parentd22fc0dd931e43be5f20526e8e43a303d054ca21 (diff)
Fix an off by one error.
-rw-r--r--src/librc/librc-misc.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/librc/librc-misc.c b/src/librc/librc-misc.c
index 8cbd6a6d..afd078dd 100644
--- a/src/librc/librc-misc.c
+++ b/src/librc/librc-misc.c
@@ -108,6 +108,7 @@ librc_hidden_def(rc_strcatpaths)
char *rc_getline (FILE *fp)
{
char *line = NULL;
+ char *p;
size_t len = 0;
size_t last = 0;
@@ -117,8 +118,9 @@ char *rc_getline (FILE *fp)
do {
len += BUFSIZ;
line = xrealloc (line, sizeof (char) * len);
- fgets (line + last, BUFSIZ, fp);
- last = strlen (line + last) - 1;
+ p = line + last;
+ fgets (p, BUFSIZ, fp);
+ last += strlen (p);
} while (! feof (fp) && line[last] != '\n');
/* Trim the trailing newline */