From bf31d98414a7374e8900a7c52f1f2eda279a1c76 Mon Sep 17 00:00:00 2001 From: Thomas Arp <357770+welcor@users.noreply.github.com> Date: Sun, 19 Jan 2020 14:40:33 +0100 Subject: [PATCH] Make sure all followers are free'd before freeing the character list Otherwise, the followers structs will point to free'd memory and the stop_follower call will attempt to dereference a free'd characters' followers list. --- src/db.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/db.c b/src/db.c index 002dcc4..746b3a2 100644 --- a/src/db.c +++ b/src/db.c @@ -501,15 +501,22 @@ static void free_extra_descriptions(struct extra_descr_data *edesc) void destroy_db(void) { ssize_t cnt, itr; - struct char_data *chtmp; + struct char_data *chtmp, *i = character_list; struct obj_data *objtmp; /* Active Mobiles & Players */ + while (i) { + chtmp = i; + i = i->next; + + if (chtmp->master) + stop_follower(chtmp); + } + while (character_list) { chtmp = character_list; character_list = character_list->next; - if (chtmp->master) - stop_follower(chtmp); + free_char(chtmp); }