From 76bcdc63f8e4b7e2c108f9828284a4ee03021770 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Mon, 7 Jun 2004 08:33:21 -0700 Subject: [PATCH] Make sure we don't silently accept an empty expression following unary expressions. --- expression.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/expression.c b/expression.c index c628d1ea..9e2863e5 100644 --- a/expression.c +++ b/expression.c @@ -374,10 +374,20 @@ static struct token *unary_expression(struct token *token, struct expression **t if (match_oplist(token->special, SPECIAL_INCREMENT, SPECIAL_DECREMENT, '&', '*', '+', '-', '~', '!', 0)) { - struct expression *unary = alloc_expression(token->pos, EXPR_PREOP); + struct expression *unop; + struct expression *unary; + struct token *next; + + next = cast_expression(token->next, &unop); + if (!unop) { + warn(token->pos, "Syntax error in unary expression"); + return next; + } + unary = alloc_expression(token->pos, EXPR_PREOP); unary->op = token->special; + unary->unop = unop; *tree = unary; - return cast_expression(token->next, &unary->unop); + return next; } /* Gcc extension: &&label gives the address of a label */ -- 2.11.4.GIT