From 03e87437e31fb134d77041f57d5d944daaf32225 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 4 Dec 2017 09:38:29 +0100 Subject: Gracefully handle deletion of a picture that doesn't exist The list iteration in dive_remove_picture() was buggy and would crash if handled a picture that is not in the list. Signed-off-by: Berthold Stoeger --- core/dive.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'core/dive.c') diff --git a/core/dive.c b/core/dive.c index 033139d0c..f37ad6272 100644 --- a/core/dive.c +++ b/core/dive.c @@ -3841,9 +3841,9 @@ struct picture *clone_picture(struct picture *src) void dive_remove_picture(char *filename) { struct picture **picture = ¤t_dive->picture_list; - while (picture && !same_string((*picture)->filename, filename)) + while (*picture && !same_string((*picture)->filename, filename)) picture = &(*picture)->next; - if (picture) { + if (*picture) { struct picture *temp = (*picture)->next; picture_free(*picture); *picture = temp; -- cgit v1.2.3-70-g09d2