[Scummvm-git-logs] scummvm master -> d2745ff37f86442f69c3e630ba84aa6d7bf64228
bluegr
noreply at scummvm.org
Sat May 27 08:06:13 UTC 2023
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
d2745ff37f SAGA: Fix memory and file handle leak in loadResource
Commit: d2745ff37f86442f69c3e630ba84aa6d7bf64228
https://github.com/scummvm/scummvm/commit/d2745ff37f86442f69c3e630ba84aa6d7bf64228
Author: PushmePullyu (127053144+PushmePullyu at users.noreply.github.com)
Date: 2023-05-27T11:06:08+03:00
Commit Message:
SAGA: Fix memory and file handle leak in loadResource
Fixes #14334
Changed paths:
engines/saga/resource.cpp
diff --git a/engines/saga/resource.cpp b/engines/saga/resource.cpp
index 871a111b688..f37adb2ab01 100644
--- a/engines/saga/resource.cpp
+++ b/engines/saga/resource.cpp
@@ -490,11 +490,11 @@ void Resource::loadResource(ResourceContext *context, uint32 resourceId, ByteArr
ResourceData *resourceData = context->getResourceData(resourceId);
Common::SeekableReadStream *file = nullptr;
uint32 resourceOffset = resourceData->offset;
+ Common::File actualFile;
if (resourceData->diskNum == -1)
file = context->getFile(resourceData);
else {
- Common::File *actualFile = new Common::File();
Common::String fileName = context->_fileName;
int sz = fileName.size();
while(sz > 0 && fileName[sz - 1] != '.')
@@ -505,9 +505,9 @@ void Resource::loadResource(ResourceContext *context, uint32 resourceId, ByteArr
fileName = Common::String::format("%s%02d.adf", fileName.substr(0, sz).c_str(), resourceData->diskNum + 1);
else
fileName = Common::String::format("%s.%03d", fileName.substr(0, sz).c_str(), resourceData->diskNum);
- if (!actualFile->open(fileName))
+ if (!actualFile.open(fileName))
error("Resource::loadResource() failed to open %s", fileName.c_str());
- file = actualFile;
+ file = &actualFile;
}
debug(8, "loadResource %d 0x%X:0x%X", resourceId, resourceOffset, uint(resourceData->size));
More information about the Scummvm-git-logs
mailing list