summaryrefslogtreecommitdiff
path: root/misc.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 /misc.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 'misc.c')
-rw-r--r--misc.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/misc.c b/misc.c
index cfd32729a..af24fa5c4 100644
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: misc.c,v 1.109 2017/03/14 00:55:37 dtucker Exp $ */ 1/* $OpenBSD: misc.c,v 1.110 2017/05/31 09:15:42 deraadt Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * Copyright (c) 2005,2006 Damien Miller. All rights reserved. 4 * Copyright (c) 2005,2006 Damien Miller. All rights reserved.
@@ -539,7 +539,7 @@ addargs(arglist *args, char *fmt, ...)
539 } else if (args->num+2 >= nalloc) 539 } else if (args->num+2 >= nalloc)
540 nalloc *= 2; 540 nalloc *= 2;
541 541
542 args->list = xreallocarray(args->list, nalloc, sizeof(char *)); 542 args->list = xrecallocarray(args->list, args->nalloc, nalloc, sizeof(char *));
543 args->nalloc = nalloc; 543 args->nalloc = nalloc;
544 args->list[args->num++] = cp; 544 args->list[args->num++] = cp;
545 args->list[args->num] = NULL; 545 args->list[args->num] = NULL;