summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2008-02-23 08:13:08 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2008-02-23 08:13:08 +0000
commitb603697a4d7606f67713cea9749b8f03172f10d7 (patch)
tree1b9460b6eee179e5cffd8515908e29ec7fa6354d
parent02429484a70b33ac9d64d0df166acfe5db868928 (diff)
if the first call to allocset() fails, the second might deref a NULL
pointer, so add a safety-net. From Gianluigi Tiesi via Torok Edwin. ok chl@ millert@
-rw-r--r--lib/libc/regex/regcomp.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c
index 022e20da32b..5b632c8b7dd 100644
--- a/lib/libc/regex/regcomp.c
+++ b/lib/libc/regex/regcomp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: regcomp.c,v 1.18 2007/10/10 21:23:44 chl Exp $ */
+/* $OpenBSD: regcomp.c,v 1.19 2008/02/23 08:13:07 otto Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994 Henry Spencer.
* Copyright (c) 1992, 1993, 1994
@@ -1051,6 +1051,9 @@ allocset(struct parse *p)
(void) memset((char *)p->g->setbits + (nbytes - css), 0, css);
}
+ /* XXX should not happen */
+ if (p->g->sets == NULL || p->g->setbits == NULL)
+ goto nomem;
cs = &p->g->sets[no];
cs->ptr = p->g->setbits + css*((no)/CHAR_BIT);