Currently we segfault when len == 0 for an attribute list.
essentially [cons: =0, 1, 2, 3; attrs: ] segfaults but should be equivalent to
[cons: =0, 1, 2, 3] and [cons: =0, 1, 2, 3; attrs:]. This fixes it by just
returning early and leaving it to the validators whether this should error out
or not.
gcc/ChangeLog:
* gensupport.cc (conlist): Support length 0 attribute.
conlist (const char *ns, unsigned int len, bool numeric)
{
/* Trim leading whitespaces. */
- while (ISBLANK (*ns))
+ while (len > 0 && ISBLANK (*ns))
{
ns++;
len--;
break;
/* Parse off any modifiers. */
- while (!ISALNUM (*ns))
+ while (len > 0 && !ISALNUM (*ns))
{
con += *(ns++);
len--;