From: Tamar Christina Date: Fri, 4 Aug 2023 12:48:56 +0000 (+0100) Subject: gensupport: Don't segfault on empty attrs list X-Git-Tag: basepoints/gcc-15~7149 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b80071a4d05c9535d3bb26cddaed0895a414f59;p=thirdparty%2Fgcc.git gensupport: Don't segfault on empty attrs list 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. --- diff --git a/gcc/gensupport.cc b/gcc/gensupport.cc index 959d1d9c83cf..b2feb03363ac 100644 --- a/gcc/gensupport.cc +++ b/gcc/gensupport.cc @@ -620,7 +620,7 @@ public: conlist (const char *ns, unsigned int len, bool numeric) { /* Trim leading whitespaces. */ - while (ISBLANK (*ns)) + while (len > 0 && ISBLANK (*ns)) { ns++; len--; @@ -632,7 +632,7 @@ public: break; /* Parse off any modifiers. */ - while (!ISALNUM (*ns)) + while (len > 0 && !ISALNUM (*ns)) { con += *(ns++); len--;