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 target of firstaid_activity_actor disappears
Prevents segfault when performing `firstaid_activity_actor` but the bandage tool disappeared. Backtrace of fixed segfault: ``` Thread 1 "cataclysm-tiles" received signal SIGSEGV, Segmentation fault. (gdb) bt #0 0x0000555555ece5a4 in item::get_usable_item_helper<item> (use_name="heal", self=...) at src/item.cpp:11584 #1 item::get_usable_item (this=0x0, use_name="heal") at src/item.cpp:11606 #2 0x000055555599c6bf in firstaid_activity_actor::finish (this=0x55559b583f20, act=..., who=...) at src/activity_actor.cpp:6651 #3 0x00005555564d8c6b in player_activity::do_turn (this=0x555558108218, you=...) at src/player_activity.cpp:391 #4 0x0000555555ce3fa6 in do_turn () at src/do_turn.cpp:532 #5 0x000055555577511a in main (argc=<optimized out>, argv=<optimized out>) at src/main.cpp:873 ``` An example where this happened was when the bandage was inside a spillable container (clay canning pot), that spilled its contents when starting the activity. Spiling the clay canning pot invalidates the `item_location`. Backtrace of when the clay canning pot was spilled: ``` #0 item_pocket::get_name (this=0x555557fa7540) at src/item_pocket.cpp:2117 #1 item_pocket::handle_liquid_or_spill (this=this@entry=0x555557fa7540, guy=..., avoid=0x555557fa8060) at src/item_pocket.cpp:806 #2 0x0000555555a6aa60 in avatar_action::use_item (you=..., loc=..., method="heal") at src/avatar_action.cpp:1212 #3 0x0000555555a6dda7 in avatar_action::eat_or_use (you=..., loc=...) at src/avatar_action.cpp:988 #4 0x0000555555e3e1c5 in game::do_regular_action (this=this@entry=0x555557f94a60, act=@0x7fffffffd1b0: ACTION_EAT, player_character=..., mouse_target=std::optional [no contained value]) at src/handle_action.cpp:2479 #5 0x0000555555e41260 in game::handle_action (this=0x555557f94a60) at src/handle_action.cpp:3176 #6 0x0000555555ce422f in do_turn () at /usr/include/c++/13/bits/unique_ptr.h:199 #7 0x000055555577511a in main (argc=<optimized out>, argv=<optimized out>) at src/main.cpp:873 ```
- Loading branch information