Make sure all followers are free'd before freeing the character list (#75)

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.
This commit is contained in:
Thomas Arp 2020-01-19 14:44:21 +01:00 committed by wyld-sw
parent 934d83b829
commit 1ab51a0545

View file

@ -501,15 +501,22 @@ static void free_extra_descriptions(struct extra_descr_data *edesc)
void destroy_db(void) void destroy_db(void)
{ {
ssize_t cnt, itr; ssize_t cnt, itr;
struct char_data *chtmp; struct char_data *chtmp, *i = character_list;
struct obj_data *objtmp; struct obj_data *objtmp;
/* Active Mobiles & Players */ /* Active Mobiles & Players */
while (i) {
chtmp = i;
i = i->next;
if (chtmp->master)
stop_follower(chtmp);
}
while (character_list) { while (character_list) {
chtmp = character_list; chtmp = character_list;
character_list = character_list->next; character_list = character_list->next;
if (chtmp->master)
stop_follower(chtmp);
free_char(chtmp); free_char(chtmp);
} }