aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Snover2017-11-10 23:21:46 -0600
committerColin Snover2017-11-10 23:22:26 -0600
commit925c9416db8ae2361d8f444823621b869a1d210f (patch)
tree75e589cbfe67ef0f32fae27e6ce9650da5297779
parenta8eddb2fc4d2aa29d306bc8ac7744c9c8bbb429b (diff)
downloadscummvm-rg350-925c9416db8ae2361d8f444823621b869a1d210f.tar.gz
scummvm-rg350-925c9416db8ae2361d8f444823621b869a1d210f.tar.bz2
scummvm-rg350-925c9416db8ae2361d8f444823621b869a1d210f.zip
SWORD1: Fix use of deallocated stack memory
FSNode::getName returns a String object, not a reference, so the pointer from c_str is valid only until the end of the statement.
-rw-r--r--engines/sword1/detection.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/engines/sword1/detection.cpp b/engines/sword1/detection.cpp
index 53ddfca213..d4343c8a9f 100644
--- a/engines/sword1/detection.cpp
+++ b/engines/sword1/detection.cpp
@@ -161,9 +161,8 @@ void Sword1CheckDirectory(const Common::FSList &fslist, bool *filesFound, bool r
if (directory.hasPrefix("clusters") && directory.size() <= 9 && !recursion)
continue;
- const char *fileName = file->getName().c_str();
for (int cnt = 0; cnt < NUM_FILES_TO_CHECK; cnt++)
- if (scumm_stricmp(fileName, g_filesToCheck[cnt]) == 0)
+ if (scumm_stricmp(file->getName().c_str(), g_filesToCheck[cnt]) == 0)
filesFound[cnt] = true;
} else {
for (int cnt = 0; cnt < ARRAYSIZE(g_dirNames); cnt++)