I started activating new program_state.saving and discovered that saving of ball and chain could access freed memory. The change for the former and fix for the latter are mixed together here (but easily distinguishable). The saving flag inhibits status updating and perm_invent updating, also map updating that goes through flush_screen(). That should fix the exception triggered after an impossible warning was issued during a save operation. impossible() goes through pline() which tries to bring the screen up to date before issuing a message. During save, data for that update can be in an inconsistent state. The code to save ball and/or chain when not on floor or in invent (I think swallowed is the only expected case) was examining the memory pointed to by uball and uchain even if saving the level had just freed floor objects and saving invent had just freed carried objects. So for the usual cases, stale pointer values for uball and uchain would be present and checking their obj->where field was not reliable.
38 KiB
38 KiB