diff options
author | 2014-10-18 04:12:28 +0000 | |
---|---|---|
committer | 2014-10-18 04:12:28 +0000 | |
commit | 59b76012d7fa97d2698dc963d31582a6e368977a (patch) | |
tree | f5877f8b8383a0e659c49e52f3d14c3b15fe45d3 /lib/libc/regex/regcomp.c | |
parent | Convert some malloc() and realloc() calls to reallocarray(). (diff) | |
download | wireguard-openbsd-59b76012d7fa97d2698dc963d31582a6e368977a.tar.xz wireguard-openbsd-59b76012d7fa97d2698dc963d31582a6e368977a.zip |
reallocarray() -- a little tricky to review
ok doug millert
Diffstat (limited to 'lib/libc/regex/regcomp.c')
-rw-r--r-- | lib/libc/regex/regcomp.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c index d52febf337d..68d20abf904 100644 --- a/lib/libc/regex/regcomp.c +++ b/lib/libc/regex/regcomp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: regcomp.c,v 1.25 2014/09/08 15:45:20 tedu Exp $ */ +/* $OpenBSD: regcomp.c,v 1.26 2014/10/18 04:12:28 deraadt Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 Henry Spencer. * Copyright (c) 1992, 1993, 1994 @@ -1047,16 +1047,16 @@ allocset(struct parse *p) p->ncsalloc += CHAR_BIT; nc = p->ncsalloc; assert(nc % CHAR_BIT == 0); - nbytes = nc / CHAR_BIT * css; ptr = reallocarray(p->g->sets, nc, sizeof(cset)); if (ptr == NULL) goto nomem; p->g->sets = ptr; - ptr = realloc(p->g->setbits, nbytes); + ptr = reallocarray(p->g->setbits, nc / CHAR_BIT, css); if (ptr == NULL) goto nomem; + nbytes = (nc / CHAR_BIT) * css; p->g->setbits = ptr; for (i = 0; i < no; i++) |