From 0659ca4846d6b7eade11628e35c6dad6bf876e49 Mon Sep 17 00:00:00 2001 From: whiterandrek Date: Sun, 10 Jun 2018 04:21:01 +0300 Subject: PINK: fix mem leaks --- engines/pink/objects/pages/game_page.cpp | 1 + engines/pink/objects/sequences/sequencer.cpp | 4 ++++ engines/pink/objects/walk/walk_mgr.cpp | 6 ++++++ engines/pink/objects/walk/walk_mgr.h | 1 + engines/pink/pink.cpp | 1 + engines/pink/sound.cpp | 2 +- 6 files changed, 14 insertions(+), 1 deletion(-) diff --git a/engines/pink/objects/pages/game_page.cpp b/engines/pink/objects/pages/game_page.cpp index 5bd420c442..e0d5de1c3c 100644 --- a/engines/pink/objects/pages/game_page.cpp +++ b/engines/pink/objects/pages/game_page.cpp @@ -36,6 +36,7 @@ GamePage::GamePage() GamePage::~GamePage() { clear(); + delete _memFile; } void GamePage::toConsole() { diff --git a/engines/pink/objects/sequences/sequencer.cpp b/engines/pink/objects/sequences/sequencer.cpp index 8facfe32e9..30048814fb 100644 --- a/engines/pink/objects/sequences/sequencer.cpp +++ b/engines/pink/objects/sequences/sequencer.cpp @@ -40,6 +40,10 @@ Sequencer::~Sequencer() { for (uint i = 0; i < _sequences.size(); ++i) { delete _sequences[i]; } + for (uint i = 0; i < _timers.size(); ++i) { + delete _timers[i]; + } + removeContext(_context); } void Sequencer::deserialize(Archive &archive) { diff --git a/engines/pink/objects/walk/walk_mgr.cpp b/engines/pink/objects/walk/walk_mgr.cpp index c7c06ec474..1336991aba 100644 --- a/engines/pink/objects/walk/walk_mgr.cpp +++ b/engines/pink/objects/walk/walk_mgr.cpp @@ -32,6 +32,12 @@ namespace Pink { WalkMgr::WalkMgr() : _isWalking(false), _leadActor(nullptr) {} +WalkMgr::~WalkMgr() { + for (uint i = 0; i < _locations.size(); ++i) { + delete _locations[i]; + } +} + void WalkMgr::deserialize(Pink::Archive &archive) { _leadActor = static_cast(archive.readObject()); _locations.deserialize(archive); diff --git a/engines/pink/objects/walk/walk_mgr.h b/engines/pink/objects/walk/walk_mgr.h index cb6b68c31c..a836bfc522 100644 --- a/engines/pink/objects/walk/walk_mgr.h +++ b/engines/pink/objects/walk/walk_mgr.h @@ -42,6 +42,7 @@ struct Coordinates { class WalkMgr : public Object { public: WalkMgr(); + ~WalkMgr() override; virtual void deserialize(Archive &archive); void toConsole() override; diff --git a/engines/pink/pink.cpp b/engines/pink/pink.cpp index eaeadbcd2e..d28b05828d 100644 --- a/engines/pink/pink.cpp +++ b/engines/pink/pink.cpp @@ -261,6 +261,7 @@ Common::Error PinkEngine::loadGameState(int slot) { _nextPage = archive.readString(); initModule(archive.readString(), "", &archive); + delete in; return Common::kNoError; } diff --git a/engines/pink/sound.cpp b/engines/pink/sound.cpp index 81463b29bf..5771951e3e 100644 --- a/engines/pink/sound.cpp +++ b/engines/pink/sound.cpp @@ -39,7 +39,7 @@ void Sound::play(Common::SafeSeekableSubReadStream *stream, Audio::Mixer::SoundT mixer->stopHandle(_handle); Audio::AudioStream *audioStream; - Audio::SeekableAudioStream *wavStream = Audio::makeWAVStream(stream, DisposeAfterUse::NO); + Audio::SeekableAudioStream *wavStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES); if (isLoop) audioStream = Audio::makeLoopingAudioStream(wavStream, 0, 0, 0); else -- cgit v1.2.3