aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorThierry Crozat2013-06-30 13:45:43 -0600
committerThierry Crozat2013-06-30 13:45:43 -0600
commit8c070963684933f72581cc061f3aaf5c71960af8 (patch)
tree04b33de8987b0ff4a64edf22ef967a792afd6116 /engines
parent730a1373d9837c340e6e646aaa4fbdce4574620a (diff)
downloadscummvm-rg350-8c070963684933f72581cc061f3aaf5c71960af8.tar.gz
scummvm-rg350-8c070963684933f72581cc061f3aaf5c71960af8.tar.bz2
scummvm-rg350-8c070963684933f72581cc061f3aaf5c71960af8.zip
MORTEVIELLE: Fix memory leak with the _screenSurface
The _screenSurface was not free'ed after being created. This is now done at the end of run() (the Surface is created at the start of run() when calling initialise()). Also moved a few free() from the destructor to the end of run() in case run() can be called more than once on the same engine.
Diffstat (limited to 'engines')
-rw-r--r--engines/mortevielle/mortevielle.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/engines/mortevielle/mortevielle.cpp b/engines/mortevielle/mortevielle.cpp
index 7220cd6b58..46c7c75fa3 100644
--- a/engines/mortevielle/mortevielle.cpp
+++ b/engines/mortevielle/mortevielle.cpp
@@ -101,10 +101,6 @@ MortevielleEngine::MortevielleEngine(OSystem *system, const ADGameDescription *g
}
MortevielleEngine::~MortevielleEngine() {
- // Allocated from run() > initialise() > loadCFIPH()
- free(_speechManager._cfiphBuffer);
- // Allocated from run() > initialise() > loadCFIEC()
- free(_cfiecBuffer);
}
/**
@@ -174,8 +170,10 @@ Common::ErrorCode MortevielleEngine::initialise() {
// Load the mort.dat resource
Common::ErrorCode result = loadMortDat();
- if (result != Common::kNoError)
+ if (result != Common::kNoError) {
+ _screenSurface.free();
return result;
+ }
// Load some error messages (was previously in chartex())
_hintPctMessage = getString(580); // You should have noticed %d hints
@@ -341,6 +339,11 @@ Common::Error MortevielleEngine::run() {
// Run the main game loop
mainGame();
+
+ // Cleanup (allocated in initialise())
+ _screenSurface.free();
+ free(_speechManager._cfiphBuffer);
+ free(_cfiecBuffer);
return Common::kNoError;
}