summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2004-03-21 19:50:17 +0000
committerJim Meyering <jim@meyering.net>2004-03-21 19:50:17 +0000
commit846d81da01e516cdd9a7965e05f823e7e47abff4 (patch)
tree476510c99e35b0557660f958be208763178d746f /lib
parent9fb05110ea7084a1f60d20df650c32533af0cac9 (diff)
downloadcoreutils-846d81da01e516cdd9a7965e05f823e7e47abff4.tar.xz
(readtoken): Don't leak 64 bytes when reading an empty input stream.
Diffstat (limited to 'lib')
-rw-r--r--lib/readtokens.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/readtokens.c b/lib/readtokens.c
index 0fe8a9498..438441c4e 100644
--- a/lib/readtokens.c
+++ b/lib/readtokens.c
@@ -111,13 +111,14 @@ readtoken (FILE *stream,
i = 0;
for (;;)
{
+ if (c < 0 && i == 0)
+ return -1;
+
if (i == n)
p = x2nrealloc (p, &n, sizeof *p);
if (c < 0)
{
- if (i == 0)
- return -1;
p[i] = 0;
break;
}