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 <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2017-12-04 09:38:29 +01:00 committed by Lubomir I. Ivanov
parent cab0699d4c
commit 03e87437e3

View file

@ -3841,9 +3841,9 @@ struct picture *clone_picture(struct picture *src)
void dive_remove_picture(char *filename)
{
struct picture **picture = &current_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;