Initialise the `positions' array correctly before use.
This commit is contained in:
parent
aa37be50ad
commit
f457179a13
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=97328
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user