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 /regexec.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 'regexec.c')
-rw-r--r-- | regexec.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -3381,7 +3381,7 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state) if (BE (ndests <= 0, 0)) { if (dests_node_malloced) - free (dests_alloc); + re_free (dests_alloc); /* Return 0 in case of an error, 1 otherwise. */ if (ndests == 0) { @@ -3413,18 +3413,18 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state) else #endif { - dest_states = (re_dfastate_t **) - malloc (ndests * 3 * sizeof (re_dfastate_t *)); + dest_states = + re_malloc (re_dfastate_t *, ndests * 3); if (BE (dest_states == NULL, 0)) { out_free: if (dest_states_malloced) - free (dest_states); + re_free (dest_states); re_node_set_free (&follows); for (i = 0; i < ndests; ++i) re_node_set_free (dests_node + i); if (dests_node_malloced) - free (dests_alloc); + re_free (dests_alloc); return 0; } dest_states_malloced = true; @@ -3555,14 +3555,14 @@ out_free: } if (dest_states_malloced) - free (dest_states); + re_free (dest_states); re_node_set_free (&follows); for (i = 0; i < ndests; ++i) re_node_set_free (dests_node + i); if (dests_node_malloced) - free (dests_alloc); + re_free (dests_alloc); return 1; } @@ -4225,7 +4225,7 @@ match_ctx_clean (re_match_context_t *mctx) re_free (top->path->array); re_free (top->path); } - free (top); + re_free (top); } mctx->nsub_tops = 0; |