From a8eddb2fc4d2aa29d306bc8ac7744c9c8bbb429b Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Fri, 10 Nov 2017 23:19:49 -0600 Subject: SKY: 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. --- engines/sky/detection.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/engines/sky/detection.cpp b/engines/sky/detection.cpp index 4b91f50a61..b5425f9532 100644 --- a/engines/sky/detection.cpp +++ b/engines/sky/detection.cpp @@ -151,9 +151,7 @@ GameList SkyMetaEngine::detectGames(const Common::FSList &fslist) const { // Iterate over all files in the given directory for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) { if (!file->isDirectory()) { - const char *fileName = file->getName().c_str(); - - if (0 == scumm_stricmp("sky.dsk", fileName)) { + if (0 == scumm_stricmp("sky.dsk", file->getName().c_str())) { Common::File dataDisk; if (dataDisk.open(*file)) { hasSkyDsk = true; @@ -161,7 +159,7 @@ GameList SkyMetaEngine::detectGames(const Common::FSList &fslist) const { } } - if (0 == scumm_stricmp("sky.dnr", fileName)) { + if (0 == scumm_stricmp("sky.dnr", file->getName().c_str())) { Common::File dinner; if (dinner.open(*file)) { hasSkyDnr = true; -- cgit v1.2.3