buf_size: don't crash on invalid code
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 6 Feb 2013 18:23:40 +0000 (6 21:23 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Wed, 6 Feb 2013 18:23:40 +0000 (6 21:23 +0300)
The code which triggers this can't compile, but I spent some time figuring
out why Smatch crashed so now I'm committing this change.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch_buf_size.c

index 8fa5416..cab2de2 100644 (file)
@@ -211,7 +211,7 @@ static int get_real_array_size(struct expression *expr)
 
 static int get_size_from_initializer(struct expression *expr)
 {
-       if (expr->type != EXPR_SYMBOL || !expr->symbol->initializer)
+       if (expr->type != EXPR_SYMBOL || !expr->symbol || !expr->symbol->initializer)
                return 0;
        if (expr->symbol->initializer == expr) /* int a = a; */
                return 0;