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 | d14278c71c190ee93f3a8fbe0db5fe9f64fcee24 (patch) | |
tree | b979660d5a5719053862183ee172a781e317d0ba /mdoc_argv.c | |
parent | bd8fc166fb7a4aad04578dee7fe7fc209d5e1488 (diff) | |
download | mandoc-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_argv.c')
-rw-r--r-- | mdoc_argv.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/mdoc_argv.c b/mdoc_argv.c index bc469896..c35c4157 100644 --- a/mdoc_argv.c +++ b/mdoc_argv.c @@ -359,8 +359,8 @@ mdoc_argv(struct mdoc *mdoc, int line, enum mdoct tok, arg = *v = mandoc_calloc(1, sizeof(struct mdoc_arg)); arg->argc++; - arg->argv = mandoc_realloc(arg->argv, - arg->argc * sizeof(struct mdoc_argv)); + arg->argv = mandoc_reallocarray(arg->argv, + arg->argc, sizeof(struct mdoc_argv)); memcpy(&arg->argv[(int)arg->argc - 1], &tmp, sizeof(struct mdoc_argv)); @@ -667,8 +667,8 @@ argv_multi(struct mdoc *mdoc, int line, break; if (0 == v->sz % MULTI_STEP) - v->value = mandoc_realloc(v->value, - (v->sz + MULTI_STEP) * sizeof(char *)); + v->value = mandoc_reallocarray(v->value, + v->sz + MULTI_STEP, sizeof(char *)); v->value[(int)v->sz] = mandoc_strdup(p); } |