]> git.ipfire.org Git - thirdparty/libbsd.git/commitdiff
Fix buffer leaks in fgetln
authorGuillem Jover <guillem@hadrons.org>
Fri, 15 May 2009 19:26:09 +0000 (21:26 +0200)
committerGuillem Jover <guillem@hadrons.org>
Fri, 15 May 2009 19:26:09 +0000 (21:26 +0200)
Cache the size and the buffer allocated by getline as static variables.

src/fgetln.c

index 2e6eac91d156745b242a76378b4412cea6db8c3e..33b261b6217c0cdec34888d801a4549fed557470 100644 (file)
@@ -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);