Fix a bug in get_line_from_file. If the length of the line is (GROWBY * n) +
GROWBY - 1, then it writes the null character just after the buffer. Yipe. Fix thanks to Matt Kraai <kraai@alumni.carnegiemellon.edu> Thanks Matt! -Erik
This commit is contained in:
parent
f12724c21a
commit
161cf93404
@ -1616,7 +1616,7 @@ extern char *get_line_from_file(FILE *file)
|
||||
if (ch == EOF)
|
||||
break;
|
||||
/* grow the line buffer as necessary */
|
||||
if (idx > linebufsz-1)
|
||||
if (idx > linebufsz-2)
|
||||
linebuf = realloc(linebuf, linebufsz += GROWBY);
|
||||
linebuf[idx++] = (char)ch;
|
||||
if ((char)ch == '\n')
|
||||
|
Loading…
x
Reference in New Issue
Block a user