diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2003-09-26 21:26:41 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2003-09-26 21:26:41 +0000 |
commit | 63bb5173c800c402d2b0e943fb52b30ec97afecb (patch) | |
tree | 73c916ea4d3c9d1940b4657c4ea217b815e951af /usr.bin/cap_mkdb/cap_mkdb.c | |
parent | e183ff4e645844d44a2e5ccefab11b4e5135c148 (diff) |
better realloc. ok deraadt@
Diffstat (limited to 'usr.bin/cap_mkdb/cap_mkdb.c')
-rw-r--r-- | usr.bin/cap_mkdb/cap_mkdb.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/usr.bin/cap_mkdb/cap_mkdb.c b/usr.bin/cap_mkdb/cap_mkdb.c index 23dba7b4593..1df575c3735 100644 --- a/usr.bin/cap_mkdb/cap_mkdb.c +++ b/usr.bin/cap_mkdb/cap_mkdb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cap_mkdb.c,v 1.12 2003/09/21 22:32:02 millert Exp $ */ +/* $OpenBSD: cap_mkdb.c,v 1.13 2003/09/26 21:25:34 tedu Exp $ */ /* $NetBSD: cap_mkdb.c,v 1.5 1995/09/02 05:47:12 jtc Exp $ */ /*- @@ -40,7 +40,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)cap_mkdb.c 8.2 (Berkeley) 4/27/95"; #endif -static char rcsid[] = "$OpenBSD: cap_mkdb.c,v 1.12 2003/09/21 22:32:02 millert Exp $"; +static char rcsid[] = "$OpenBSD: cap_mkdb.c,v 1.13 2003/09/26 21:25:34 tedu Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -174,9 +174,13 @@ db_build(char **ifiles) */ len = strlen(bp); if (bplen <= len + 2) { - bplen += MAX(256, len + 2); - if ((data.data = realloc(data.data, bplen)) == NULL) + int newbplen = bplen + MAX(256, len + 2); + void *newdata; + + if ((newdata = realloc(data.data, newbplen)) == NULL) err(1, NULL); + data.data = newdata; + bplen = newbplen; } /* Find the end of the name field. */ |