Fix logic in nth_mixer_scene (amend 00bd313e6e)

_mixer_scenes[nth] may not exist, size check condition needs
to happen first. Writer lock is only required when changing the
vector.
This commit is contained in:
Robin Gareus 2022-06-01 16:26:51 +02:00
parent ca8dddcd37
commit ef4bbae02e
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -7525,7 +7525,10 @@ boost::shared_ptr<MixerScene>
Session::nth_mixer_scene (size_t nth, bool create_if_missing)
{
Glib::Threads::RWLock::ReaderLock lm (_mixer_scenes_lock);
if (create_if_missing && (!_mixer_scenes[nth] || _mixer_scenes.size() <= nth) ) {
if (create_if_missing) {
if (_mixer_scenes.size() > nth && _mixer_scenes[nth]) {
return _mixer_scenes[nth];
}
lm.release ();
Glib::Threads::RWLock::WriterLock lw (_mixer_scenes_lock);
if (_mixer_scenes.size() <= nth) {