luciensadi / AwakeMUD

The Community Edition fork of the 'Awakened Worlds' Shadowrun 3 MUD codebase.
Other
55 stars 30 forks source link

Fix for hedit 'x' crash, v.2 #745

Open jdevnull opened 1 month ago

jdevnull commented 1 month ago
  1. When host changes are saved, we call collate_host_entrances to rebuild entrance lists. Thus, when deleting host A, we don't need to search other hosts for entrances pointing to host A. This solves the issue of trying to find an entrance in another host that may not (yet) exist.

  2. It makes sense to clear host A's own list of entrances as part of free_host instead of in hedit.

  3. When making a copy of an existing host for editing in olc, we don't want the copy to point to the existing host's list of entrances. This solves the issue where we can end up with a pointer directing us to freed memory. We also don't need to make a copy of the list because collate_host_entrances will rebuild the list if/when we save, so we can just set it to null.

luciensadi commented 1 month ago

Looks like the crashes were caused by the entrance linked list not being cloned on hedit. This caused the actual host's entrances to be blown away when the edited host was extracted, which broke memory constraints.

jdevnull commented 1 month ago

Yeah, this was what I was trying to describe in part 3 of the PR description. That said, we don't actually need to clone the entrance list, since they're going to be rebuilt anyway - we just need the copy to not point to the actual host's linked list, so we can just assign it to null.