From 7651de361a9045f734ced6f790d44b85c2c91cb9 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 3 Jun 2014 07:48:35 -0700 Subject: [PATCH] Don't crash when looping over pictures for a null dive Signed-off-by: Dirk Hohndel --- dive.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dive.h b/dive.h index 0ff22e607..737278181 100644 --- a/dive.h +++ b/dive.h @@ -291,8 +291,9 @@ struct picture { struct picture *next; }; -#define FOR_EACH_PICTURE( DIVE ) \ - for(struct picture *picture = DIVE->picture_list; picture; picture = picture->next) +#define FOR_EACH_PICTURE(_dive) \ + if (_dive) \ + for (struct picture *picture = (_dive)->picture_list; picture; picture = picture->next) extern struct picture *alloc_picture();