diff options
-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); } } |