diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-19 21:04:32 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-19 21:04:32 -0700 |
commit | 5343861e409cb1f6f4dd710a7e7feecb079fbd94 (patch) | |
tree | 69f62f9efb813a242aaefd5556c53a0bd83519dc /expression.c | |
parent | Fix SIGSEGV on assignment to bad left side. (diff) | |
download | sparse-5343861e409cb1f6f4dd710a7e7feecb079fbd94.tar.gz sparse-5343861e409cb1f6f4dd710a7e7feecb079fbd94.tar.bz2 sparse-5343861e409cb1f6f4dd710a7e7feecb079fbd94.zip |
Fix assignment and conditional expression parsing with no left side.
We used to parse it with a NULL left side, which just doesn't make
any sense. Refuse to recognize it instead.
Diffstat (limited to 'expression.c')
-rw-r--r-- | expression.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/expression.c b/expression.c index 8a1b40e..310aa17 100644 --- a/expression.c +++ b/expression.c @@ -696,7 +696,7 @@ static struct token *logical_or_expression(struct token *token, struct expressio struct token *conditional_expression(struct token *token, struct expression **tree) { token = logical_or_expression(token, tree); - if (match_op(token, '?')) { + if (*tree && match_op(token, '?')) { struct expression *expr = alloc_expression(token->pos, EXPR_CONDITIONAL); expr->op = token->special; expr->left = *tree; @@ -711,7 +711,7 @@ struct token *conditional_expression(struct token *token, struct expression **tr struct token *assignment_expression(struct token *token, struct expression **tree) { token = conditional_expression(token, tree); - if (token_type(token) == TOKEN_SPECIAL) { + if (*tree && token_type(token) == TOKEN_SPECIAL) { static const int assignments[] = { '=', SPECIAL_ADD_ASSIGN, SPECIAL_SUB_ASSIGN, |