diff options
author | Max Horn | 2007-03-20 18:59:28 +0000 |
---|---|---|
committer | Max Horn | 2007-03-20 18:59:28 +0000 |
commit | f5559de703a2deca65f6a716fdf6e68aa7413607 (patch) | |
tree | a794402cc00727777bfeb9463377c8be7cf4dc85 /engines/scumm/imuse_digi/dimuse_script.cpp | |
parent | e56b44d1fa47574c1ff109f687caad13fec50150 (diff) | |
download | scummvm-rg350-f5559de703a2deca65f6a716fdf6e68aa7413607.tar.gz scummvm-rg350-f5559de703a2deca65f6a716fdf6e68aa7413607.tar.bz2 scummvm-rg350-f5559de703a2deca65f6a716fdf6e68aa7413607.zip |
Fix a potential race condition (leading to lockups) in IMuseDigital::refreshScripts
svn-id: r26254
Diffstat (limited to 'engines/scumm/imuse_digi/dimuse_script.cpp')
-rw-r--r-- | engines/scumm/imuse_digi/dimuse_script.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/engines/scumm/imuse_digi/dimuse_script.cpp b/engines/scumm/imuse_digi/dimuse_script.cpp index 1a257c905f..ad976e3300 100644 --- a/engines/scumm/imuse_digi/dimuse_script.cpp +++ b/engines/scumm/imuse_digi/dimuse_script.cpp @@ -189,16 +189,20 @@ void IMuseDigital::flushTracks() { } void IMuseDigital::refreshScripts() { - Common::StackLock lock(_mutex, "IMuseDigital::refreshScripts()"); - debug(5, "refreshScripts()"); - bool found = false; - for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { - Track *track = _track[l]; - if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) { - found = true; + { + Common::StackLock lock(_mutex, "IMuseDigital::refreshScripts()"); + debug(5, "refreshScripts()"); + bool found = false; + for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { + Track *track = _track[l]; + if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) { + found = true; + } } } - + + // Make sure parseScriptCmds is *not* called while the mutex is locked + // (else race conditions can occur). if (!found && (_curMusicSeq != 0)) { debug(5, "refreshScripts() Start Sequence"); parseScriptCmds(0x1001, 0, 0, 0, 0, 0, 0, 0); |