Skip to content

Commit

Permalink
Prevents possible use after free in sounds (cataclysmbnteam#3412)
Browse files Browse the repository at this point in the history
  • Loading branch information
joveeater authored Oct 12, 2023
1 parent 1b7d0db commit 029b0bd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/sounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@ void sounds::process_sound_markers( player *p )
bool is_deaf = p->is_deaf();
const float volume_multiplier = p->hearing_ability();
const int weather_vol = get_weather().weather_id->sound_attn;
for( const auto &sound_event_pair : sounds_since_last_turn ) {
auto sounds_copy = sounds_since_last_turn;
for( const auto &sound_event_pair : sounds_copy ) {
const tripoint &pos = sound_event_pair.first;
const sound_event &sound = sound_event_pair.second;
const int distance_to_sound = sound_distance( p->pos(), pos );
Expand Down

0 comments on commit 029b0bd

Please sign in to comment.