aboutsummaryrefslogtreecommitdiff
path: root/engines/sky
diff options
context:
space:
mode:
authorColin Snover2017-11-10 23:19:49 -0600
committerColin Snover2017-11-10 23:22:25 -0600
commita8eddb2fc4d2aa29d306bc8ac7744c9c8bbb429b (patch)
tree289c3089825ac10de8beea9dd1d0a0127a092ce5 /engines/sky
parent6b4195a542083c97f696c843b9823d578b018996 (diff)
downloadscummvm-rg350-a8eddb2fc4d2aa29d306bc8ac7744c9c8bbb429b.tar.gz
scummvm-rg350-a8eddb2fc4d2aa29d306bc8ac7744c9c8bbb429b.tar.bz2
scummvm-rg350-a8eddb2fc4d2aa29d306bc8ac7744c9c8bbb429b.zip
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.
Diffstat (limited to 'engines/sky')
-rw-r--r--engines/sky/detection.cpp6
1 files 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;