summaryrefslogtreecommitdiffstats
path: root/usr.bin/mandoc/manpath.c
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2014-04-23 21:06:33 +0000
committerschwarze <schwarze@openbsd.org>2014-04-23 21:06:33 +0000
commit8286bf36f2392472edfeb9324ecb47a787501e38 (patch)
tree6f6a7d3a994e74079e6fae86d8a1b664952c82c2 /usr.bin/mandoc/manpath.c
parentnull pointers after free to prevent double frees and worse. also fix a (diff)
downloadwireguard-openbsd-8286bf36f2392472edfeb9324ecb47a787501e38.tar.xz
wireguard-openbsd-8286bf36f2392472edfeb9324ecb47a787501e38.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 'usr.bin/mandoc/manpath.c')
-rw-r--r--usr.bin/mandoc/manpath.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/mandoc/manpath.c b/usr.bin/mandoc/manpath.c
index 05045ca749a..76b1f3d8abb 100644
--- a/usr.bin/mandoc/manpath.c
+++ b/usr.bin/mandoc/manpath.c
@@ -1,4 +1,4 @@
-/* $Id: manpath.c,v 1.9 2014/04/20 16:44:44 schwarze Exp $ */
+/* $Id: manpath.c,v 1.10 2014/04/23 21:06:33 schwarze Exp $ */
/*
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -119,8 +119,8 @@ manpath_add(struct manpaths *dirs, const char *dir)
if (0 == strcmp(dirs->paths[i], dir))
return;
- dirs->paths = mandoc_realloc(dirs->paths,
- (dirs->sz + 1) * sizeof(char *));
+ dirs->paths = mandoc_reallocarray(dirs->paths,
+ dirs->sz + 1, sizeof(char *));
dirs->paths[dirs->sz++] = mandoc_strdup(cp);
}