Prevent segfault when refitting item in spillable container #75687
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Bugfixes "Prevent segfault when refitting item in spillable container"
Purpose of change
Prevents segfault from accessing an invalidated
item_location
when refitting an item that was stored inside a spillable container. Fixes #74254 .Describe the solution
The previous segfault could be reproduced by having an inventory like:
And then using a tailor's kit to refit the t-shirt caused a segfault. Part of refitting will invalidate items inside the aluminum can, which is a spillable container, and dereferencing the tshirt after having repaired it will segfault.
This change instead makes sure that we do not use
fix_location
after we have calledrepair_item_actor::repair
. It also adds a unit test that reproduced the previous segfault (but works on this branch).Describe alternatives you've considered
Testing
Can no longer reproduce the segfault in #74254 . All of the work clothing items can now be repaired:
Additional context
It's odd that we were able to put the tshirt in the can in the first place, since it's a spillable container, and that should not be possible in a backpack. But that's for a different issue.