Skip to content

Commit

Permalink
fix: prevent use of non valid creature pointer (CleverRaven#60272)
Browse files Browse the repository at this point in the history
  • Loading branch information
dseguin authored and Hirmuolio committed Aug 27, 2022
1 parent 873c383 commit 54d9076
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/effect_on_condition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,12 @@ void effect_on_conditions::write_global_eocs_to_file( )
void effect_on_conditions::avatar_death()
{
avatar &player_character = get_avatar();
dialogue d( get_talker_for( get_avatar() ),
player_character.get_killer() == nullptr ? nullptr : get_talker_for(
player_character.get_killer() ) );
Creature *klr = player_character.get_killer();
// Make sure the creature still exists in game
klr = !klr ? klr : g->get_creature_if( [klr]( const Creature & c ) {
return klr == &c;
} );
dialogue d( get_talker_for( get_avatar() ), klr == nullptr ? nullptr : get_talker_for( klr ) );
for( const effect_on_condition &eoc : effect_on_conditions::get_all() ) {
if( eoc.type == eoc_type::AVATAR_DEATH ) {
eoc.activate( d );
Expand Down

0 comments on commit 54d9076

Please sign in to comment.