From: Guillem Jover Date: Wed, 9 Jul 2008 05:22:30 +0000 (+0300) Subject: fgetln: Fix function to make it actually work X-Git-Tag: 0.0~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=47109e39d5995c7addaa932625fb0ea1e0e8200a;p=thirdparty%2Flibbsd.git fgetln: Fix function to make it actually work Reported by Thorsten Glaser. --- diff --git a/src/fgetln.c b/src/fgetln.c index c92aa82..9f2a584 100644 --- a/src/fgetln.c +++ b/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 */