[colobot] 286/377: Prevent possible crashes related to not releasing pause
Didier Raboud
odyx at moszumanska.debian.org
Wed Mar 30 13:34:28 UTC 2016
This is an automated email from the git hooks/post-receive script.
odyx pushed a commit to branch debian/master
in repository colobot.
commit 999b2b85a4cd956e2c8370466f267c18c5b93bfe
Author: krzys-h <krzys_h at interia.pl>
Date: Tue Feb 16 12:23:21 2016 +0100
Prevent possible crashes related to not releasing pause
---
src/app/pausemanager.cpp | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/app/pausemanager.cpp b/src/app/pausemanager.cpp
index 7fd901c..ead940a 100644
--- a/src/app/pausemanager.cpp
+++ b/src/app/pausemanager.cpp
@@ -64,15 +64,26 @@ void CPauseManager::DeactivatePause(ActivePause* pause)
{
if (pause == nullptr) return;
//GetLogger()->Debug("Deactivated pause mode - %s\n", GetPauseName(pause->type).c_str());
- m_activePause.erase(std::remove_if(
+ auto it = std::remove_if(
m_activePause.begin(), m_activePause.end(),
- [&](const std::unique_ptr<ActivePause>& x) { return x.get() == pause; })
+ [&](const std::unique_ptr<ActivePause>& x) { return x.get() == pause; }
);
+ if (it == m_activePause.end())
+ {
+ GetLogger()->Warn("Releasing previously not deactivated pause now!\n");
+ std::free(pause);
+ }
+ m_activePause.erase(it);
Update();
}
void CPauseManager::FlushPause()
{
+ for (auto& pause : m_activePause)
+ {
+ GetLogger()->Warn("Pause not deactivated before phase change!\n");
+ pause.release();
+ }
m_activePause.clear();
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git
More information about the Pkg-games-commits
mailing list