summaryrefslogtreecommitdiff
path: root/lib/libc/regex/regcomp.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1998-08-14 21:39:45 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1998-08-14 21:39:45 +0000
commitfbe7a4e21ce2effe646980ca1214c125d94c70fd (patch)
tree50eb4ae3c83a05be96515dfbe68af415625afbfa /lib/libc/regex/regcomp.c
parenteef299572b3aae714384affd3dae3292c7325f78 (diff)
realloc repair
Diffstat (limited to 'lib/libc/regex/regcomp.c')
-rw-r--r--lib/libc/regex/regcomp.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c
index 8e8cc319f62..0964bbf27e0 100644
--- a/lib/libc/regex/regcomp.c
+++ b/lib/libc/regex/regcomp.c
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)regcomp.c 8.5 (Berkeley) 3/20/94";
#else
-static char rcsid[] = "$OpenBSD: regcomp.c,v 1.5 1997/04/30 05:51:09 tholo Exp $";
+static char rcsid[] = "$OpenBSD: regcomp.c,v 1.6 1998/08/14 21:39:35 deraadt Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
@@ -1248,16 +1248,21 @@ register cset *cs;
register char *cp;
{
register size_t oldend = cs->smultis;
+ void *np;
cs->smultis += strlen(cp) + 1;
if (cs->multis == NULL)
- cs->multis = malloc(cs->smultis);
+ np = malloc(cs->smultis);
else
- cs->multis = realloc(cs->multis, cs->smultis);
- if (cs->multis == NULL) {
+ np = realloc(cs->multis, cs->smultis);
+ if (np == NULL) {
+ if (cs->multis)
+ free(cs->multis);
+ cs->multis = NULL;
SETERROR(REG_ESPACE);
return;
}
+ cs->multis = np;
(void) strcpy(cs->multis + oldend - 1, cp);
cs->multis[cs->smultis - 1] = '\0';