From f18b5ea7d27d1ba1b520520400e132821b5206ff Mon Sep 17 00:00:00 2001 From: Philipp Dreher Date: Sun, 1 Nov 2015 18:54:29 +0100 Subject: [PATCH] general check for sf->faction's validity The handling of an ally without a valid faction-pointer is now skipped in favor of a logged error. --- src/kernel/save.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/kernel/save.c b/src/kernel/save.c index 300555180..b70583fc8 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1346,11 +1346,16 @@ void writefaction(struct gamedata *data, const faction * f) WRITE_SECTION(data->store); for (sf = f->allies; sf; sf = sf->next) { - int no = (sf->faction != NULL) ? sf->faction->no : 0; - int status = alliedfaction(NULL, f, sf->faction, HELP_ALL); - if (status != 0) { - WRITE_INT(data->store, no); - WRITE_INT(data->store, sf->status); + if (sf->faction != NULL) { + int no = sf->faction->no; + int status = alliedfaction(NULL, f, sf->faction, HELP_ALL); + if (status != 0) { + WRITE_INT(data->store, no); + WRITE_INT(data->store, sf->status); + } + } + else { + log_error("NULL-pointer in ally-struct for faction '%s'.", f->no); } } WRITE_INT(data->store, 0);