summaryrefslogtreecommitdiffstats
path: root/bitmap.c
diff options
context:
space:
mode:
authorderaadt@openbsd.org <deraadt@openbsd.org>2017-05-31 09:15:42 +0000
committerDamien Miller <djm@mindrot.org>2017-06-01 14:55:22 +1000
commit9e509d4ec97cb3d71696f1a2f1fdad254cbbce11 (patch)
tree8f33ae8fa9bcfa0d9c80d0e0f1555a814a844bc1 /bitmap.c
parentdc5dc45662773c0f7745c29cf77ae2d52723e55e (diff)
upstream commit
Switch to recallocarray() for a few operations. Both growth and shrinkage are handled safely, and there also is no need for preallocation dances. Future changes in this area will be less error prone. Review and one bug found by markus Upstream-ID: 822d664d6a5a1d10eccb23acdd53578a679d5065
Diffstat (limited to 'bitmap.c')
-rw-r--r--bitmap.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/bitmap.c b/bitmap.c
index 3d7aa137..71f87ec5 100644
--- a/bitmap.c
+++ b/bitmap.c
@@ -87,7 +87,7 @@ reserve(struct bitmap *b, u_int n)
return -1; /* invalid */
nlen = (n / BITMAP_BITS) + 1;
if (b->len < nlen) {
- if ((tmp = reallocarray(b->d, nlen, BITMAP_BYTES)) == NULL)
+ if ((tmp = recallocarray(b->d, b->len, nlen, BITMAP_BYTES)) == NULL)
return -1;
b->d = tmp;
memset(b->d + b->len, 0, (nlen - b->len) * BITMAP_BYTES);