On 07/23/2016 06:33 AM, Aldy Hernandez wrote:
If the REGEX_MALLOC mode in regex.c is unused, can I rip it out? I'd
like to replace it all with alloca with a malloc fallback.
And yes, I realize regex.c already does this most of the time:
if (size1 > MAX_ALLOCA_SIZE)
{
wcs_string1 = TALLOC (size1 + 1, CHAR_T);
mbs_offset1 = TALLOC (size1 + 1, int);
is_binary = TALLOC (size1 + 1, char);
}
else
{
wcs_string1 = REGEX_TALLOC (size1 + 1, CHAR_T);
mbs_offset1 = REGEX_TALLOC (size1 + 1, int);
is_binary = REGEX_TALLOC (size1 + 1, char);
}
But there are other uses of REGEX_TALLOC that seem to call alloca()
without any bound checks (where REGEX_TALLOC can be defined as alloca):
if (bufp->re_nsub)
{
regstart = REGEX_TALLOC (num_regs, const CHAR_T *);
regend = REGEX_TALLOC (num_regs, const CHAR_T *);
...
...
}
and:
if (csize1 != 0)
{
string1 = REGEX_TALLOC (csize1 + 1, CHAR_T);
mbs_offset1 = REGEX_TALLOC (csize1 + 1, int);
is_binary = REGEX_TALLOC (csize1 + 1, char);
...
}
etc etc.
Cheerios.
Aldy