public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-2990] gensupport: Don't segfault on empty attrs list
@ 2023-08-04 12:50 Tamar Christina
0 siblings, 0 replies; only message in thread
From: Tamar Christina @ 2023-08-04 12:50 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:6b80071a4d05c9535d3bb26cddaed0895a414f59
commit r14-2990-g6b80071a4d05c9535d3bb26cddaed0895a414f59
Author: Tamar Christina <tamar.christina@arm.com>
Date: Fri Aug 4 13:48:56 2023 +0100
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:
---
gcc/gensupport.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gcc/gensupport.cc b/gcc/gensupport.cc
index 959d1d9c83c..b2feb03363a 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--;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-08-04 12:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-04 12:50 [gcc r14-2990] gensupport: Don't segfault on empty attrs list Tamar Christina
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).