From: Guillem Jover Date: Fri, 15 May 2009 19:26:09 +0000 (+0200) Subject: Fix buffer leaks in fgetln X-Git-Tag: 0.1.0~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=74ae34e792a08de78ab671a683abdf48c27eccd3;p=thirdparty%2Flibbsd.git Fix buffer leaks in fgetln Cache the size and the buffer allocated by getline as static variables. --- diff --git a/src/fgetln.c b/src/fgetln.c index 2e6eac9..33b261b 100644 --- a/src/fgetln.c +++ b/src/fgetln.c @@ -34,8 +34,8 @@ char * fgetln (FILE *stream, size_t *len) { - char *line = NULL; - size_t line_len = 0; + static char *line = NULL; + static size_t line_len = 0; ssize_t nread; nread = getline(&line, &line_len, stream);