[PATCH] Set *tree to NULL on error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Vegard Nossum <vegardno@xxxxxxxxxx>
Date: Sun, 25 May 2008 10:29:19 +0200
Subject: [PATCH] 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@xxxxxxxxxx>
---
 expression.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/expression.c b/expression.c
index 289927a..f634b07 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);
-- 
1.5.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux