From 64e0eba682896a84bd32d8edab846d2bb8dff2fa Mon Sep 17 00:00:00 2001 From: Christoph Mallon Date: Thu, 16 Jun 2011 15:29:40 +0200 Subject: [PATCH] Correct off-by-one error when checking whether the end of the GNU attribute list was reached. --- parser.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/parser.c b/parser.c index 17f1a62..4fc3804 100644 --- a/parser.c +++ b/parser.c @@ -1273,21 +1273,22 @@ static attribute_t *parse_attribute_gnu_single(void) next_token(); attribute_kind_t kind; - for (kind = ATTRIBUTE_GNU_FIRST; kind <= ATTRIBUTE_GNU_LAST; ++kind) { + for (kind = ATTRIBUTE_GNU_FIRST;; ++kind) { + if (kind > ATTRIBUTE_GNU_LAST) { + if (warning.attribute) { + warningf(HERE, "unknown attribute '%s' ignored", name); + } + /* TODO: we should still save the attribute in the list... */ + kind = ATTRIBUTE_UNKNOWN; + break; + } + const char *attribute_name = get_attribute_name(kind); if (attribute_name != NULL && strcmp_underscore(attribute_name, name) == 0) break; } - if (kind >= ATTRIBUTE_GNU_LAST) { - if (warning.attribute) { - warningf(HERE, "unknown attribute '%s' ignored", name); - } - /* TODO: we should still save the attribute in the list... */ - kind = ATTRIBUTE_UNKNOWN; - } - attribute_t *attribute = allocate_attribute_zero(kind); /* parse arguments */ -- 2.20.1