From fb067c8f63910d7ce22ee1a1f4a1af679c3cf768 Mon Sep 17 00:00:00 2001 From: tjr Date: Mon, 27 May 2002 02:01:25 +0000 Subject: Initialise the `positions' array correctly before use. --- usr.bin/cut/cut.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'usr.bin/cut/cut.c') 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); } } -- cgit v1.1