Prevent segfault on unload_activity_actor #70575
Merged
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 on unload_activity_actor"
Purpose of change
Describe the solution
Previous segfault being fixed:
The problem before was that the reference to
target
inunload_activity_actor::unload
was an invalid reference. This was caused by:unload_activity_actor::finish
callsact.set_to_null()
.null
type (=no current activity)unload_activity_actor::unload
isstatic
, and takestarget
as a reference.::unload
callsCharacter::add_or_drop_with_msg
which leads to call chain:liquid_handler::consume_liquid
->get_liquid_target
->choose_adjacent
->choose_direction
->temp_hide_advanced_inv
->advanced_inventory::temp_hide
->advanced_inventory::do_return_entry
advanced_inventory::do_return_entry
assigns a newACT_ADV_INVENTORY
activity. This invalidates the previousunload_activity_actor
because of pt 2 above.unload_activity_actor::unload
resumes after its call toadd_or_drop_with_msg
, the reference totarget
is invalid because of pt 5.This commit attempt to fix the issue with invalidated
target
reference by copying its value before invalidating the activity.Describe alternatives you've considered
Testing
Additional context