From dd38e424e7ec87990019f4a811fdc25c62fe1729 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 2 Aug 2010 22:27:26 +0000 Subject: SCI: Fix leaks in ResourceManager::listResources caller code. svn-id: r51666 --- engines/sci/console.cpp | 3 ++- engines/sci/detection.cpp | 2 +- engines/sci/engine/features.cpp | 3 +++ engines/sci/engine/kscripts.cpp | 1 + engines/sci/resource.cpp | 1 + 5 files changed, 8 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp index 7407f08482..bac31f6c8e 100644 --- a/engines/sci/console.cpp +++ b/engines/sci/console.cpp @@ -844,6 +844,7 @@ bool Console::cmdVerifyScripts(int argc, const char **argv) { } DebugPrintf("SCI1.1-SCI2.1 script check finished\n"); + delete resources; return true; } @@ -1006,6 +1007,7 @@ bool Console::cmdShowInstruments(int argc, const char **argv) { DebugPrintf("\n\n"); } + delete resources; return true; } @@ -1051,7 +1053,6 @@ bool Console::cmdList(int argc, const char **argv) { ++itr; } DebugPrintf("\n"); - delete resources; } diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp index 3a8e10fd84..e330bd5f30 100644 --- a/engines/sci/detection.cpp +++ b/engines/sci/detection.cpp @@ -299,7 +299,7 @@ Common::String convertSierraGameId(Common::String sierraId, uint32 *gameFlags, R if (sierraId == "fp" || sierraId == "gk" || sierraId == "pq4") demoThreshold = 150; - Common::List *resources = resMan->listResources(kResourceTypeScript, -1); + Common::ScopedPtr > resources(resMan->listResources(kResourceTypeScript, -1)); if (resources->size() < demoThreshold) { *gameFlags |= ADGF_DEMO; diff --git a/engines/sci/engine/features.cpp b/engines/sci/engine/features.cpp index ad6d4d728d..f99d412c64 100644 --- a/engines/sci/engine/features.cpp +++ b/engines/sci/engine/features.cpp @@ -438,6 +438,8 @@ SciVersion GameFeatures::detectMessageFunctionType() { Common::List *resources = g_sci->getResMan()->listResources(kResourceTypeMessage, -1); if (resources->empty()) { + delete resources; + // No messages found, so this doesn't really matter anyway... _messageFunctionType = SCI_VERSION_1_1; return _messageFunctionType; @@ -445,6 +447,7 @@ SciVersion GameFeatures::detectMessageFunctionType() { Resource *res = g_sci->getResMan()->findResource(*resources->begin(), false); assert(res); + delete resources; // Only v2 Message resources use the kGetMessage kernel function. // v3-v5 use the kMessage kernel function. diff --git a/engines/sci/engine/kscripts.cpp b/engines/sci/engine/kscripts.cpp index e211867ef9..a5501c160f 100644 --- a/engines/sci/engine/kscripts.cpp +++ b/engines/sci/engine/kscripts.cpp @@ -95,6 +95,7 @@ reg_t kLock(EngineState *s, int argc, reg_t *argv) { ++itr; } + delete resources; } else { which = g_sci->getResMan()->findResource(id, 0); diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp index 2fdf091314..d59b21eef6 100644 --- a/engines/sci/resource.cpp +++ b/engines/sci/resource.cpp @@ -665,6 +665,7 @@ int ResourceManager::addInternalSources() { ++itr; } + delete resources; return 1; } -- cgit v1.2.3