Resolve another null pointer access.
authorChristoph Mallon <christoph.mallon@gmx.de>
Sat, 29 Nov 2008 15:24:29 +0000 (15:24 +0000)
committerChristoph Mallon <christoph.mallon@gmx.de>
Sat, 29 Nov 2008 15:24:29 +0000 (15:24 +0000)
[r24143]

ast.c

diff --git a/ast.c b/ast.c
index c084a7f..036c7c7 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -1036,9 +1036,13 @@ static void print_declaration_statement(
 {
        bool first = true;
        entity_t *entity = statement->declarations_begin;
-       for (;
-                entity != statement->declarations_end->base.next;
-                entity = entity->base.next) {
+       if (entity == NULL) {
+               fputs("/* empty declaration statement */\n", out);
+               return;
+       }
+
+       entity_t *const end = statement->declarations_end->base.next;
+       for (; entity != end; entity = entity->base.next) {
                if (!is_declaration(entity) && entity->kind != ENTITY_TYPEDEF)
                        continue;
                if (is_generated_entity(entity))