aboutsummaryrefslogtreecommitdiff
path: root/common/file.cpp
diff options
context:
space:
mode:
authorJohannes Schickel2007-11-11 08:08:40 +0000
committerJohannes Schickel2007-11-11 08:08:40 +0000
commit2387a642e50d5fb39ae370dd29cbee0083529813 (patch)
treeec30b7e31dfd54fe9dcbece78982097b46644849 /common/file.cpp
parent1bae92f2e1ba13a57239024942676cf33fec82b0 (diff)
downloadscummvm-rg350-2387a642e50d5fb39ae370dd29cbee0083529813.tar.gz
scummvm-rg350-2387a642e50d5fb39ae370dd29cbee0083529813.tar.bz2
scummvm-rg350-2387a642e50d5fb39ae370dd29cbee0083529813.zip
Committed patch #1829748 "Fix for memory leaks in File::exists".
svn-id: r29474
Diffstat (limited to 'common/file.cpp')
-rw-r--r--common/file.cpp25
1 files changed, 10 insertions, 15 deletions
diff --git a/common/file.cpp b/common/file.cpp
index be557ff634..2bf65abf62 100644
--- a/common/file.cpp
+++ b/common/file.cpp
@@ -412,33 +412,28 @@ bool File::open(const FilesystemNode &node, AccessMode mode) {
}
bool File::exists(const String &filename) {
- FilesystemNode* file;
- String fname = filename;
-
// First try to find the file via a FilesystemNode (in case an absolute
// path was passed). This is only used to filter out directories.
- file = new FilesystemNode(fname);
- if (file->exists())
- return !file->isDirectory();
+ FilesystemNode file(filename);
+ if (file.exists())
+ return !file.isDirectory();
// See if the file is already mapped
- if (_filesMap && _filesMap->contains(fname)) {
- fname = (*_filesMap)[fname];
- file = new FilesystemNode(fname);
+ if (_filesMap && _filesMap->contains(filename)) {
+ FilesystemNode file2((*_filesMap)[filename]);
- if (file->exists())
- return !file->isDirectory();
+ if (file2.exists())
+ return !file2.isDirectory();
}
// Try all default directories
if (_defaultDirectories) {
StringIntMap::const_iterator i(_defaultDirectories->begin());
for (; i != _defaultDirectories->end(); ++i) {
- fname = i->_key+fname;
- file = new FilesystemNode(fname);
+ FilesystemNode file2(i->_key + filename);
- if(file->exists())
- return !file->isDirectory();
+ if(file2.exists())
+ return !file2.isDirectory();
}
}