diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2015-04-13 10:09:04 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2015-04-13 10:09:04 +0300 |
commit | 0325b4daf737414c3b811b05c70b897b807a436b (patch) | |
tree | 4facae80910096029530389c2832fa91dd60a8cc /regcomp.c | |
parent | 89c079e54f1e3a49df1f2653ba5fe40d834cd8c3 (diff) | |
download | egawk-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.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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; |