open_toontown_panda3d/panda
John C. Allwein 81f7a21845 openal: fix potential iterator invalidation in OpenALAudioManager::update
OpenALAudioManager::update iterates through all currently playing sounds
via a std::set / phash_set object, _sounds_playing.

If a stream queue corruption was detected during OpenALAudioSound::pull_used_buffers,
the logic added in a895890 would call cleanup() on
the sound if we could not successfully locate the target buffer and log an error.

However, the act of calling OpenALAudioSound::cleanup would lead to calling
stop() (since the sound was actively playing). In OpenALAudioSound::stop(),
we would then proceed to call _manager->stopping_sound which would erase
the current sound from _sounds_playing (while we still held an iterator
to it). Per STL standard and real-world observation, std::set::erase
will invalidate the current iterator held in update (https://en.cppreference.com/w/cpp/container/set/erase).
This leads to a segmentation fault when we attempt the next iteration on the loop.

To resolve this, let's ensure we don't hold onto invalid iterators during the updating of playing sounds.

Fixes #1452
2023-02-12 14:13:02 +01:00
..
metalibs dxml: Remove TinyXML bindings 2022-11-03 13:45:22 +01:00
src openal: fix potential iterator invalidation in OpenALAudioManager::update 2023-02-12 14:13:02 +01:00
CMakeLists.txt Merge branch 'release/1.10.x' 2022-11-21 19:02:50 +01:00