From ade7336daf432e50e683318f01b7d2c1296e79b7 Mon Sep 17 00:00:00 2001 From: Christoph Mallon Date: Sat, 29 Nov 2008 15:24:29 +0000 Subject: [PATCH] Resolve another null pointer access. [r24143] --- ast.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ast.c b/ast.c index c084a7f..036c7c7 100644 --- 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)) -- 2.20.1