summaryrefslogtreecommitdiffstats
path: root/mdoc_validate.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 /mdoc_validate.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 'mdoc_validate.c')
-rw-r--r--mdoc_validate.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 0a2e8eb5..a3029926 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1460,8 +1460,8 @@ post_bl_block_tag(POST_ARGS)
assert(n->args);
i = (int)(n->args->argc)++;
- n->args->argv = mandoc_realloc(n->args->argv,
- n->args->argc * sizeof(struct mdoc_argv));
+ n->args->argv = mandoc_reallocarray(n->args->argv,
+ n->args->argc, sizeof(struct mdoc_argv));
n->args->argv[i].arg = MDOC_Width;
n->args->argv[i].line = n->line;
@@ -1521,8 +1521,8 @@ post_bl_head(POST_ARGS)
*/
np->args->argv[j].sz = (size_t)mdoc->last->nchild;
- np->args->argv[j].value = mandoc_malloc(
- (size_t)mdoc->last->nchild * sizeof(char *));
+ np->args->argv[j].value = mandoc_reallocarray(NULL,
+ (size_t)mdoc->last->nchild, sizeof(char *));
mdoc->last->norm->Bl.ncols = np->args->argv[j].sz;
mdoc->last->norm->Bl.cols = (void *)np->args->argv[j].value;