diff options
author | tjr <tjr@FreeBSD.org> | 2002-05-27 02:01:25 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2002-05-27 02:01:25 +0000 |
commit | fb067c8f63910d7ce22ee1a1f4a1af679c3cf768 (patch) | |
tree | f938547bb2834909b55611c0c9804c9d1dbbf51d /usr.bin/cut | |
parent | e24a2ccd6ae611d96f384a255b6f114d71516315 (diff) | |
download | FreeBSD-src-fb067c8f63910d7ce22ee1a1f4a1af679c3cf768.zip FreeBSD-src-fb067c8f63910d7ce22ee1a1f4a1af679c3cf768.tar.gz |
Initialise the `positions' array correctly before use.
Diffstat (limited to 'usr.bin/cut')
-rw-r--r-- | usr.bin/cut/cut.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/usr.bin/cut/cut.c b/usr.bin/cut/cut.c index 1f67f2a..c229948 100644 --- a/usr.bin/cut/cut.c +++ b/usr.bin/cut/cut.c @@ -202,15 +202,18 @@ void needpos(size_t n) { static size_t npos; + size_t oldnpos; /* Grow the positions array to at least the specified size. */ if (n > npos) { + oldnpos = npos; if (npos == 0) npos = n; while (n > npos) npos *= 2; if ((positions = realloc(positions, npos)) == NULL) err(1, "realloc"); + memset((char *)positions + oldnpos, 0, npos - oldnpos); } } |