From ffcab2fa5dfea99601cd214a08cdce0a0f0d5301 Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Tue, 14 Jun 2016 20:26:32 -0500 Subject: SCI: Fix memory leaks in resource patcher --- engines/sci/resource.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines/sci/resource.cpp') diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp index 6a5af1a6d6..9f977aaefd 100644 --- a/engines/sci/resource.cpp +++ b/engines/sci/resource.cpp @@ -1352,6 +1352,7 @@ void ResourceManager::processPatch(ResourceSource *source, ResourceType resource Common::File *file = new Common::File(); if (!file->open(source->getLocationName())) { warning("ResourceManager::processPatch(): failed to open %s", source->getLocationName().c_str()); + delete source; return; } fileStream = file; @@ -1360,6 +1361,7 @@ void ResourceManager::processPatch(ResourceSource *source, ResourceType resource int fsize = fileStream->size(); if (fsize < 3) { debug("Patching %s failed - file too small", source->getLocationName().c_str()); + delete source; return; } @@ -1370,6 +1372,7 @@ void ResourceManager::processPatch(ResourceSource *source, ResourceType resource if (patchType != checkForType) { debug("Patching %s failed - resource type mismatch", source->getLocationName().c_str()); + delete source; return; } @@ -1394,6 +1397,7 @@ void ResourceManager::processPatch(ResourceSource *source, ResourceType resource if (patchDataOffset + 2 >= fsize) { debug("Patching %s failed - patch starting at offset %d can't be in file of size %d", source->getLocationName().c_str(), patchDataOffset + 2, fsize); + delete source; return; } -- cgit v1.2.3