summaryrefslogtreecommitdiffstats
path: root/mansearch.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-04-23 21:06:41 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-04-23 21:06:41 +0000
commitd14278c71c190ee93f3a8fbe0db5fe9f64fcee24 (patch)
treeb979660d5a5719053862183ee172a781e317d0ba /mansearch.c
parentbd8fc166fb7a4aad04578dee7fe7fc209d5e1488 (diff)
downloadmandoc-d14278c71c190ee93f3a8fbe0db5fe9f64fcee24.tar.gz
Audit malloc(3)/calloc(3)/realloc(3) usage.
* Change eight reallocs to reallocarray to be safe from overflows. * Change one malloc to reallocarray to be safe from overflows. * Change one calloc to reallocarray, no zeroing needed. * Change the order of arguments of three callocs (aesthetical).
Diffstat (limited to 'mansearch.c')
-rw-r--r--mansearch.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/mansearch.c b/mansearch.c
index f7c99394..e116aac9 100644
--- a/mansearch.c
+++ b/mansearch.c
@@ -328,8 +328,8 @@ mansearch(const struct mansearch *search,
mp = ohash_next(&htab, &idx)) {
if (cur + 1 > maxres) {
maxres += 1024;
- *res = mandoc_realloc(*res,
- maxres * sizeof(struct manpage));
+ *res = mandoc_reallocarray(*res,
+ maxres, sizeof(struct manpage));
}
mpage = *res + cur;
mpage->form = mp->form;
@@ -793,7 +793,7 @@ static void *
hash_halloc(size_t sz, void *arg)
{
- return(mandoc_calloc(sz, 1));
+ return(mandoc_calloc(1, sz));
}
static void *