Mercurial > gnulib
diff lib/regexec.c @ 39191:1a07ab062d06
regex: use re_malloc etc. consistently
Problem and original patch reported by Arnold Robbins in:
https://sourceware.org/ml/libc-alpha/2017-12/msg00241.html
* lib/regcomp.c (re_comp):
* lib/regexec.c (push_fail_stack, build_trtable, match_ctx_clean):
Use re_malloc/re_realloc/re_free instead of malloc/realloc/free.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Tue, 19 Dec 2017 15:53:47 -0800 |
parents | 1dc02097f427 |
children | 10eb9086bea0 |
line wrap: on
line diff
--- a/lib/regexec.c Tue Dec 19 09:05:15 2017 -0800 +++ b/lib/regexec.c Tue Dec 19 15:53:47 2017 -0800 @@ -1334,8 +1334,8 @@ if (fs->num == fs->alloc) { struct re_fail_stack_ent_t *new_array; - new_array = realloc (fs->stack, (sizeof (struct re_fail_stack_ent_t) - * fs->alloc * 2)); + new_array = re_realloc (fs->stack, struct re_fail_stack_ent_t, + fs->alloc * 2); if (new_array == NULL) return REG_ESPACE; fs->alloc *= 2; @@ -3319,7 +3319,7 @@ if (BE (ndests <= 0, 0)) { if (dests_node_malloced) - free (dests_alloc); + re_free (dests_alloc); /* Return false in case of an error, true otherwise. */ if (ndests == 0) { @@ -3349,18 +3349,17 @@ alloca (ndests * 3 * sizeof (re_dfastate_t *)); else { - 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 false; } dest_states_malloced = true; @@ -3491,14 +3490,14 @@ } 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 true; } @@ -4166,7 +4165,7 @@ re_free (top->path->array); re_free (top->path); } - free (top); + re_free (top); } mctx->nsub_tops = 0;