diff options
| author | Vegard Nossum <vegardno@ifi.uio.no> | 2008-05-25 10:29:19 +0200 |
|---|---|---|
| committer | Josh Triplett <josh@freedesktop.org> | 2008-07-14 11:19:48 -0700 |
| commit | cb08a60a883504a84ced36e1d1e16c93c69bb7e4 (patch) | |
| tree | ca41a992f3977065ab974a6cfc45f3bf0d280c73 | |
| parent | dd82c7033c4644299d3a8d7ed2f6b2422281b0cc (diff) | |
| download | sparse-dev-cb08a60a883504a84ced36e1d1e16c93c69bb7e4.tar.gz | |
Set *tree to NULL on error
On "Syntax error in unary expression", the output parameter "tree" would be left
uninitialized and subsequently used in unary_expression(), leading to segfault.
Caught by valgrind and fixed by me ;-)
Signed-off-by: Vegard Nossum <vegardno@ifi.uio.no>
| -rw-r--r-- | expression.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/expression.c b/expression.c index 289927ac..f634b079 100644 --- a/expression.c +++ b/expression.c @@ -654,6 +654,7 @@ static struct token *unary_expression(struct token *token, struct expression **t next = cast_expression(token->next, &unop); if (!unop) { sparse_error(token->pos, "Syntax error in unary expression"); + *tree = NULL; return next; } unary = alloc_expression(token->pos, EXPR_PREOP); @@ -671,6 +672,7 @@ static struct token *unary_expression(struct token *token, struct expression **t next = cast_expression(token->next, &unop); if (!unop) { sparse_error(token->pos, "Syntax error in unary expression"); + *tree = NULL; return next; } unary = alloc_expression(token->pos, EXPR_PREOP); |
