diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2003-09-26 22:24:10 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2003-09-26 22:24:10 +0000 |
commit | 17738dcbee8bacfd8a68cd4375820c4947ff55d6 (patch) | |
tree | 37af77e881cde2f3b424047b2aabd080ab96328b /usr.bin/find/misc.c | |
parent | 620a0222f490c8fe0d8dfc7b15279733cfed0593 (diff) |
better realloc. ok deraadt@ henning@
Diffstat (limited to 'usr.bin/find/misc.c')
-rw-r--r-- | usr.bin/find/misc.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/usr.bin/find/misc.c b/usr.bin/find/misc.c index ad343b56e18..0635129f850 100644 --- a/usr.bin/find/misc.c +++ b/usr.bin/find/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.9 2003/06/26 07:27:29 deraadt Exp $ */ +/* $OpenBSD: misc.c,v 1.10 2003/09/26 22:22:26 tedu Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -34,7 +34,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)misc.c 8.1 (Berkeley) 6/6/93";*/ -static char rcsid[] = "$OpenBSD: misc.c,v 1.9 2003/06/26 07:27:29 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: misc.c,v 1.10 2003/09/26 22:22:26 tedu Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -64,9 +64,15 @@ brace_subst(char *orig, char **store, char *path, int len) plen = strlen(path); for (p = *store; (ch = *orig); ++orig) if (ch == '{' && orig[1] == '}') { - while ((p - *store) + plen > len) - if (!(*store = realloc(*store, len *= 2))) + while ((p - *store) + plen > len) { + int newlen = len * 2; + char *newstore; + + if (!(newstore = realloc(*store, newlen))) err(1, NULL); + *store = newstore; + len = newlen; + } memmove(p, path, plen); p += plen; ++orig; |