Skip to content

Commit

Permalink
Bugfix: Prevent segfault when butcher target disappears (#73990)
Browse files Browse the repository at this point in the history
Stops butchering when the butcher target corpse has been either raised
or moved. Prevents segfault caused by dereferencing an invalid
`item_location`.
  • Loading branch information
inogenous authored May 22, 2024
1 parent 8bf5502 commit 5661f1c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,12 @@ void activity_handlers::butcher_do_turn( player_activity *act, Character * )
const butcher_type action = get_butcher_type( act );
const double progress = static_cast<double>( act->moves_total - act->moves_left ) /
act->moves_total;
item &corpse_item = *act->targets.back();
item_location target = act->targets.back();
if( !target || !target->is_corpse() ) {
act->set_to_null();
return;
}
item &corpse_item = *target;
corpse_item.set_var( butcher_progress_var( action ), progress );
}

Expand Down

0 comments on commit 5661f1c

Please sign in to comment.