aboutsummaryrefslogtreecommitdiffstats
path: root/regcomp.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2015-04-13 10:09:04 +0300
committerArnold D. Robbins <arnold@skeeve.com>2015-04-13 10:09:04 +0300
commit0325b4daf737414c3b811b05c70b897b807a436b (patch)
tree4facae80910096029530389c2832fa91dd60a8cc /regcomp.c
parent89c079e54f1e3a49df1f2653ba5fe40d834cd8c3 (diff)
downloadegawk-0325b4daf737414c3b811b05c70b897b807a436b.tar.gz
egawk-0325b4daf737414c3b811b05c70b897b807a436b.tar.bz2
egawk-0325b4daf737414c3b811b05c70b897b807a436b.zip
Fix regex code to avoid malloc(0).
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c7
1 files changed, 6 insertions, 1 deletions
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;