Skip to content

Commit

Permalink
Merge pull request #31519 from ymber/firing_fix
Browse files Browse the repository at this point in the history
check ammo_data return before dereferencing
  • Loading branch information
ZhilkinSerg authored Jun 16, 2019
2 parents d7848d2 + 0168c72 commit 1fa2eb7
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/avatar_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -762,8 +762,7 @@ bool avatar_action::fire( avatar &you, map &m, item &weapon, int bp_cost )
if( !gun ) {
add_msg( m_info, _( "The %s can't be fired in its current state." ), weapon.tname() );
return false;
} else if( !weapon.has_flag( "RELOAD_AND_SHOOT" ) &&
!weapon.ammo_types().count( weapon.ammo_data()->ammo->type ) ) {
} else if( weapon.ammo_data() && !weapon.ammo_types().count( weapon.ammo_data()->ammo->type ) ) {
add_msg( m_info, _( "The %s can't be fired while loaded with incompatible ammunition %s" ),
weapon.tname(), weapon.ammo_current() );
return false;
Expand Down

0 comments on commit 1fa2eb7

Please sign in to comment.