diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-04-23 21:06:41 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-04-23 21:06:41 +0000 |
commit | c4641c1dc73700968ee90de85e04b2f32fbadc8a (patch) | |
tree | 22eb558acb2454bff882d8b4571d21d8c6fd8e54 /mansearch.c | |
parent | 2255a3e49af03406199043bf555c96acf31eb877 (diff) | |
download | mandoc-c4641c1dc73700968ee90de85e04b2f32fbadc8a.tar.gz mandoc-c4641c1dc73700968ee90de85e04b2f32fbadc8a.tar.zst mandoc-c4641c1dc73700968ee90de85e04b2f32fbadc8a.zip |
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.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/mansearch.c b/mansearch.c index eec5ff13..f9892218 100644 --- a/mansearch.c +++ b/mansearch.c @@ -1,4 +1,4 @@ -/* $Id: mansearch.c,v 1.35 2014/04/23 16:34:50 schwarze Exp $ */ +/* $Id: mansearch.c,v 1.36 2014/04/23 21:06:41 schwarze Exp $ */ /* * Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -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 * |