aboutsummaryrefslogtreecommitdiff
path: root/engines/lastexpress/game/sound.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/lastexpress/game/sound.cpp')
-rw-r--r--engines/lastexpress/game/sound.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/engines/lastexpress/game/sound.cpp b/engines/lastexpress/game/sound.cpp
index 2249109fe9..b28583f729 100644
--- a/engines/lastexpress/game/sound.cpp
+++ b/engines/lastexpress/game/sound.cpp
@@ -118,9 +118,12 @@ SoundManager::SoundManager(LastExpressEngine *engine) : _engine(engine), _state(
}
SoundManager::~SoundManager() {
+ for (Common::List<SoundEntry *>::iterator i = _cache.begin(); i != _cache.end(); ++i)
+ SAFE_DELETE(*i);
+
_cache.clear();
- delete _soundStream;
+ SAFE_DELETE(_soundStream);
// Zero passed pointers
_engine = NULL;
@@ -134,6 +137,7 @@ void SoundManager::handleTimer() {
for (Common::List<SoundEntry *>::iterator i = _cache.begin(); i != _cache.end(); ++i) {
SoundEntry *entry = (*i);
if (entry->stream == NULL) {
+ SAFE_DELETE(*i);
i = _cache.reverse_erase(i);
continue;
} else if (!entry->isStreamed) {
@@ -191,7 +195,7 @@ void SoundManager::clearQueue() {
// Delete entry
removeEntry(entry);
- delete entry;
+ SAFE_DELETE(entry);
i = _cache.reverse_erase(i);
}