diff options
author | Colin Snover | 2017-05-13 22:07:53 -0500 |
---|---|---|
committer | Colin Snover | 2017-05-13 22:46:25 -0500 |
commit | f44d8b6da69a1444c76fcbce28a834f2368ddf35 (patch) | |
tree | ef2738c6e48a2b048e1b6e48a61d53ed4bec9664 /engines/sci/resource.h | |
parent | 1911b19e154b4e946d29dbf143b18cb6c9e4b660 (diff) | |
download | scummvm-rg350-f44d8b6da69a1444c76fcbce28a834f2368ddf35.tar.gz scummvm-rg350-f44d8b6da69a1444c76fcbce28a834f2368ddf35.tar.bz2 scummvm-rg350-f44d8b6da69a1444c76fcbce28a834f2368ddf35.zip |
SCI: Dispose uncached volume file streams
The stream returned by a call to ResourceManager::getVolumeFile
either MUST (when returning an I/O stream from a Common::FSNode)
or must NOT (when returning a Common::File *) be deleted by the
caller, depending upon some internal implementation details of
ResourceSource that should never have been exposed to callers.
FSNode streams that should have been deleted were not being
deleted all the time, which leaked and eventually caused ScummVM
to run out of FDs.
This commit improves this situation by shielding callers from
these internal details by centralizing the destruction logic in
one place, so FSNode read streams stop being leaked and callers
no longer need to know stuff about the internals of the
ResourceSource they are trying to read in order to avoid leaking
or breaking the volume file cache.
Fixes Trac#9782.
Diffstat (limited to 'engines/sci/resource.h')
-rw-r--r-- | engines/sci/resource.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/engines/sci/resource.h b/engines/sci/resource.h index 2bbbd42a4a..1a10fb2ccd 100644 --- a/engines/sci/resource.h +++ b/engines/sci/resource.h @@ -516,7 +516,13 @@ protected: */ const char *versionDescription(ResVersion version) const; + /** + * All calls to getVolumeFile must be followed with a corresponding + * call to disposeVolumeFileStream once the stream is finished being used. + * Do NOT call delete directly on returned streams, as they may be cached. + */ Common::SeekableReadStream *getVolumeFile(ResourceSource *source); + void disposeVolumeFileStream(Common::SeekableReadStream *fileStream, ResourceSource *source); void loadResource(Resource *res); void freeOldResources(); bool validateResource(const ResourceId &resourceId, const Common::String &sourceMapLocation, const Common::String &sourceName, const uint32 offset, const uint32 size, const uint32 sourceSize) const; |