This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [libiberty] does anyone use regex.c with REGEX_MALLOC?
- From: Aldy Hernandez <aldyh at redhat dot com>
- To: GCC Mailing List <gcc at gcc dot gnu dot org>
- Cc: Ian Lance Taylor <ian at airs dot com>, DJ Delorie <dj at redhat dot com>
- Date: Sat, 23 Jul 2016 07:29:56 -0400
- Subject: Re: [libiberty] does anyone use regex.c with REGEX_MALLOC?
- Authentication-results: sourceware.org; auth=none
- References: <57934806.70903@redhat.com>
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