Fix an off by one error.
This commit is contained in:
parent
d22fc0dd93
commit
fa898af791
@ -108,6 +108,7 @@ librc_hidden_def(rc_strcatpaths)
|
|||||||
char *rc_getline (FILE *fp)
|
char *rc_getline (FILE *fp)
|
||||||
{
|
{
|
||||||
char *line = NULL;
|
char *line = NULL;
|
||||||
|
char *p;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
size_t last = 0;
|
size_t last = 0;
|
||||||
|
|
||||||
@ -117,8 +118,9 @@ char *rc_getline (FILE *fp)
|
|||||||
do {
|
do {
|
||||||
len += BUFSIZ;
|
len += BUFSIZ;
|
||||||
line = xrealloc (line, sizeof (char) * len);
|
line = xrealloc (line, sizeof (char) * len);
|
||||||
fgets (line + last, BUFSIZ, fp);
|
p = line + last;
|
||||||
last = strlen (line + last) - 1;
|
fgets (p, BUFSIZ, fp);
|
||||||
|
last += strlen (p);
|
||||||
} while (! feof (fp) && line[last] != '\n');
|
} while (! feof (fp) && line[last] != '\n');
|
||||||
|
|
||||||
/* Trim the trailing newline */
|
/* Trim the trailing newline */
|
||||||
|
Loading…
Reference in New Issue
Block a user