From 0325b4daf737414c3b811b05c70b897b807a436b Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 13 Apr 2015 10:09:04 +0300 Subject: Fix regex code to avoid malloc(0). --- regcomp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'regcomp.c') diff --git a/regcomp.c b/regcomp.c index a3148c0e..f3dcb3ea 100644 --- a/regcomp.c +++ b/regcomp.c @@ -1217,7 +1217,12 @@ analyze (regex_t *preg) || dfa->eclosures == NULL, 0)) return REG_ESPACE; - dfa->subexp_map = re_malloc (int, preg->re_nsub); + /* some malloc()-checkers don't like zero allocations */ + if (preg->re_nsub > 0) + dfa->subexp_map = re_malloc (int, preg->re_nsub); + else + dfa->subexp_map = NULL; + if (dfa->subexp_map != NULL) { int i; -- cgit v1.2.3