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.
This commit is contained in:
Colin Snover 2017-11-10 23:21:46 -06:00
parent a8eddb2fc4
commit 925c9416db

View file

@ -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++)