diff options
author | Tamar Christina <tamar.christina@arm.com> | 2023-08-04 13:48:56 +0100 |
---|---|---|
committer | Tamar Christina <tamar.christina@arm.com> | 2023-08-04 13:48:56 +0100 |
commit | 6b80071a4d05c9535d3bb26cddaed0895a414f59 (patch) | |
tree | 16da58ed8edfbd5357e93b5b63cc207b1bca816a | |
parent | 8787b195f014883a2d2454faf2001303dfefef8c (diff) | |
download | gcc-6b80071a4d05c9535d3bb26cddaed0895a414f59.zip gcc-6b80071a4d05c9535d3bb26cddaed0895a414f59.tar.gz gcc-6b80071a4d05c9535d3bb26cddaed0895a414f59.tar.bz2 |
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.
-rw-r--r-- | gcc/gensupport.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/gensupport.cc b/gcc/gensupport.cc index 959d1d9..b2feb03 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--; |