From 699e7048f8c3a772b31a009f78cd7ea8bbad7a30 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 11 Sep 2023 17:14:02 +0300 Subject: [PATCH] parse: fix how cleanup attributes are handled Imagine you a declaration like: int a __attribute__((__cleanup__(undo))) = 1, b = 2; The cleanup attribute should only apply to a, but the original code applied it to both a and b. Signed-off-by: Dan Carpenter --- parse.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/parse.c b/parse.c index 3e801134..6803976a 100644 --- a/parse.c +++ b/parse.c @@ -1918,6 +1918,7 @@ static struct token *declaration_list(struct token *token, struct symbol_list ** saved = ctx.ctype; for (;;) { struct symbol *decl = alloc_symbol(token->pos, SYM_NODE); + ctx.cleanup = NULL; ctx.ident = &decl->ident; token = declarator(token, &ctx); @@ -3117,6 +3118,7 @@ struct token *external_declaration(struct token *token, struct symbol_list **lis ident = NULL; decl = alloc_symbol(token->pos, SYM_NODE); ctx.ctype = saved; + ctx.cleanup = NULL; token = handle_attributes(token, &ctx); token = declarator(token, &ctx); token = handle_asm_name(token, &ctx); -- 2.11.4.GIT