summaryrefslogtreecommitdiff
path: root/lib/libc/regex/regcomp.c
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2004-05-08 06:33:42 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2004-05-08 06:33:42 +0000
commit4a77af4bef16e427af1dedc49b476358b460d518 (patch)
tree145a077120171e6c56f8be6343168e59eed3d426 /lib/libc/regex/regcomp.c
parentcb224def9c98730ea5120a1eaf8a8217c00633da (diff)
When parsing what follows [, do not allocate memory that is not used,
also fix a memory leak in error path. ok millert@
Diffstat (limited to 'lib/libc/regex/regcomp.c')
-rw-r--r--lib/libc/regex/regcomp.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c
index 394fa9f53cf..9f5cabab0d9 100644
--- a/lib/libc/regex/regcomp.c
+++ b/lib/libc/regex/regcomp.c
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)regcomp.c 8.5 (Berkeley) 3/20/94";
#else
-static char rcsid[] = "$OpenBSD: regcomp.c,v 1.11 2003/12/07 06:17:17 otto Exp $";
+static char rcsid[] = "$OpenBSD: regcomp.c,v 1.12 2004/05/08 06:33:41 otto Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
@@ -670,7 +670,7 @@ static void
p_bracket(p)
register struct parse *p;
{
- register cset *cs = allocset(p);
+ register cset *cs;
register int invert = 0;
/* Dept of Truly Sickening Special-Case Kludges */
@@ -685,6 +685,8 @@ register struct parse *p;
return;
}
+ cs = allocset(p);
+
if (EAT('^'))
invert++; /* make note to invert set at end */
if (EAT(']'))
@@ -697,8 +699,10 @@ register struct parse *p;
CHadd(cs, '-');
MUSTEAT(']', REG_EBRACK);
- if (p->error != 0) /* don't mess things up further */
+ if (p->error != 0) { /* don't mess things up further */
+ freeset(p, cs);
return;
+ }
if (p->g->cflags&REG_ICASE) {
register int i;