From 8c070963684933f72581cc061f3aaf5c71960af8 Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Sun, 30 Jun 2013 13:45:43 -0600 Subject: 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. --- engines/mortevielle/mortevielle.cpp | 13 ++++++++----- 1 file 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; } -- cgit v1.2.3