>void arena_store_affects(struct char_data *ch, struct combatant_info_type >*comb) { > struct affected_type *aff, *new_aff; > > comb->affected = NULL; > > for (aff = ch->affected; aff; aff = aff->next) { > CREATE(new_aff, struct affected_type, 1); > clear_affect(new_aff); > > new_aff->type = aff->type; /* <-- Crashes here */ > new_aff->idnum = aff->idnum; > new_aff->duration = aff->duration; > new_aff->modifier = aff->modifier; > new_aff->location = aff->location; > new_aff->bitvector = aff->bitvector; > new_aff->bitvector1 = aff->bitvector1; > > new_aff->next = comb->affected; > comb->affected = new_aff; > > affect_remove(ch, aff); > > } > >} This is a fairly common mistake to make when cycling through a linked list: you have to take into account the possibility that the linked list may be modified. A simple solution is to have an aff_next pointer. If you look around the stock circle code, you'll see pointers with the same function. For example, when the mud is going through the fighting list, and one of the members in it dies (and is extracted!), what happens when you try to access ch->next_fighting? The same crash. void arena_store_affects(struct char_data *ch, struct combatant_info_type *comb) { struct affected_type *aff, *new_aff, *aff_next; /* <--- aff_next pointer */ comb->affected = NULL; for (aff = ch->affected; aff; aff = aff_next) { aff_next = aff->next; /* <--- aff->next would point to garbage once we free aff */ CREATE(new_aff, struct affected_type, 1); clear_affect(new_aff); new_aff->type = aff->type; new_aff->idnum = aff->idnum; new_aff->duration = aff->duration; new_aff->modifier = aff->modifier; new_aff->location = aff->location; new_aff->bitvector = aff->bitvector; new_aff->bitvector1 = aff->bitvector1; new_aff->next = comb->affected; comb->affected = new_aff; affect_remove(ch, aff); } } --Ben C +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 04/11/01 PDT