summaryrefslogtreecommitdiff
path: root/src/fgetln.c
diff options
context:
space:
mode:
authorGuillem Jover <guillem@hadrons.org>2009-05-15 21:26:09 +0200
committerGuillem Jover <guillem@hadrons.org>2009-05-15 21:26:09 +0200
commit74ae34e792a08de78ab671a683abdf48c27eccd3 (patch)
tree0eb9143ec537b71f2dc19cf5fa89422addd28649 /src/fgetln.c
parentdeb9f56ceb560f96448ff9bfa1befdf7ed9849de (diff)
downloadlibbsd-74ae34e792a08de78ab671a683abdf48c27eccd3.tar.gz
Fix buffer leaks in fgetln
Cache the size and the buffer allocated by getline as static variables.
Diffstat (limited to 'src/fgetln.c')
-rw-r--r--src/fgetln.c4
1 files changed, 2 insertions, 2 deletions
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);