From 925c9416db8ae2361d8f444823621b869a1d210f Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Fri, 10 Nov 2017 23:21:46 -0600 Subject: 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. --- engines/sword1/detection.cpp | 3 +-- 1 file changed, 1 insertion(+), 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++) -- cgit v1.2.3