summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorbapt <bapt@FreeBSD.org>2015-11-07 19:54:40 +0000
committerbapt <bapt@FreeBSD.org>2015-11-07 19:54:40 +0000
commit3e1b1042f9be832e2d34f2c86937e16870c23aac (patch)
tree8c9a9d2bc5dadd3ed4d537ecea2e56078dc68e4f /usr.bin
parent82a6376e2a38c9bd749accdaa434d09252c8582a (diff)
downloadFreeBSD-src-3e1b1042f9be832e2d34f2c86937e16870c23aac.zip
FreeBSD-src-3e1b1042f9be832e2d34f2c86937e16870c23aac.tar.gz
Fix an off by one due to bad conversion from avl(3) to tree(3)
Readd calloc as it was not the issue just the messenger Submitted by: dim Found by: Address Sanitizer
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/localedef/collate.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/usr.bin/localedef/collate.c b/usr.bin/localedef/collate.c
index 3216d21..7e64e6a 100644
--- a/usr.bin/localedef/collate.c
+++ b/usr.bin/localedef/collate.c
@@ -1242,11 +1242,11 @@ dump_collate(void)
}
n = 0;
RB_FOREACH(ce, elem_by_expand, &elem_by_expand) {
- n++;
(void) wsncpy(chain[n].str, ce->expand, COLLATE_STR_LEN);
for (i = 0; i < NUM_WT; i++) {
chain[n].pri[i] = get_weight(ce->ref[i], i);
}
+ n++;
}
if (n != collinfo.chain_count)
INTERR;
@@ -1255,12 +1255,11 @@ dump_collate(void)
* Large (> UCHAR_MAX) character priorities
*/
RB_NUMNODES(collchar_t, collchars, &collchars, n);
- large = malloc(sizeof (collate_large_t) * n);
+ large = calloc(n, sizeof (collate_large_t));
if (large == NULL) {
fprintf(stderr, "out of memory");
return;
}
- memset(large, 0, sizeof (collate_large_t) * n);
i = 0;
RB_FOREACH(cc, collchars, &collchars) {
OpenPOWER on IntegriCloud