mirror of
https://gitlab.freedesktop.org/libbsd/libbsd.git
synced 2025-10-23 16:48:09 +02:00
fgetln: Fix function to make it actually work
Reported by Thorsten Glaser.
This commit is contained in:
10
src/fgetln.c
10
src/fgetln.c
@@ -35,13 +35,11 @@ char *
|
||||
fgetln (FILE *stream, size_t *len)
|
||||
{
|
||||
char *line=NULL;
|
||||
size_t nread = 0;
|
||||
ssize_t nread;
|
||||
|
||||
while (nread == 1) {
|
||||
nread = getline (&line, len, stream);
|
||||
if (nread == -1)
|
||||
return NULL;
|
||||
}
|
||||
nread = getline (&line, len, stream);
|
||||
if (nread == -1)
|
||||
return NULL;
|
||||
|
||||
(*len)--; /* get rid of the trailing \0, fgetln
|
||||
does not have it */
|
||||
|
Reference in New Issue
Block a user