[Scummvm-git-logs] scummvm master -> e657e060e0f38136b6b79e6f24799c582d081200
sev-
noreply at scummvm.org
Fri Dec 9 00:28:15 UTC 2022
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
e657e060e0 DIRECTOR: Fix potential race condition
Commit: e657e060e0f38136b6b79e6f24799c582d081200
https://github.com/scummvm/scummvm/commit/e657e060e0f38136b6b79e6f24799c582d081200
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2022-12-09T01:26:32+01:00
Commit Message:
DIRECTOR: Fix potential race condition
If sound is ended during execution, we may refer to the freed memory
Changed paths:
engines/director/sound.cpp
diff --git a/engines/director/sound.cpp b/engines/director/sound.cpp
index f622f447c0d..e37a126e2eb 100644
--- a/engines/director/sound.cpp
+++ b/engines/director/sound.cpp
@@ -184,6 +184,8 @@ void DirectorSound::playCastMember(CastMemberID memberID, uint8 soundChannel, bo
// possible to gracefully stop the playback
if (looping)
_channels[soundChannel - 1].loopPtr = dynamic_cast<Audio::LoopableAudioStream *>(as);
+ else
+ _channels[soundChannel - 1].loopPtr = nullptr;
playStream(*as, soundChannel);
setLastPlayedSound(soundChannel, memberID, stopOnZero);
}
@@ -293,12 +295,15 @@ bool DirectorSound::isChannelActive(uint8 soundChannel) {
if (!isChannelValid(soundChannel))
return false;
+ if (!_mixer->isSoundHandleActive(_channels[soundChannel - 1].handle))
+ return false;
+
// Looped sounds are considered to be inactive after the first play
// WORKAROUND HACK
if (_channels[soundChannel - 1].loopPtr != nullptr)
return _channels[soundChannel - 1].loopPtr->getCompleteIterations() < 1;
- return _mixer->isSoundHandleActive(_channels[soundChannel - 1].handle);
+ return true;
}
bool DirectorSound::isChannelValid(uint8 soundChannel) {
More information about the Scummvm-git-logs
mailing list