-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent segfault when unloading from spillable container
Prevents segfault from accessing an invalidated `item_location` when unloading from a container that itself is inside a spillable container. The previous segfault could be reproduced by having an inventory like: ``` backpack > steel_pan > bottle_plastic_small > antacid tablet (1) bottle_plastic_small > antacid tablet (4) ``` And then unloading the single pill bottle caused a segfault. What happens is that part of unloading will trigger the steelpan to spill its contents. Part of spilling the contents makes the `item_location` invalidated, as previously documented in `::handle_contents_changed` in `character.h`. This commit instead makes sure that we do not use `item_location` or the item after we have called `contents_change_handler::handle_by`. From the example above, the steelpan will still spill its contents, but the segfault can no longer be reproduced. This commmit also adds a user-visible message when spilling non-liquid items.
- Loading branch information
Showing
3 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters