aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMatthew Hoops2010-06-02 02:55:55 +0000
committerMatthew Hoops2010-06-02 02:55:55 +0000
commit4493080220a98d596ee578bddc8a64c0d3955eac (patch)
treeb91e02a516192d558f3d2e3a28cd1d34d859bd15 /engines
parent767edc91faebdc1a60e5c8b3764b169dc9807ea5 (diff)
downloadscummvm-rg350-4493080220a98d596ee578bddc8a64c0d3955eac.tar.gz
scummvm-rg350-4493080220a98d596ee578bddc8a64c0d3955eac.tar.bz2
scummvm-rg350-4493080220a98d596ee578bddc8a64c0d3955eac.zip
If we can't find the game object or game ID in fallback detection, break out instead of assuming the script is there. Fixes a segfault when detecting an LSCI game.
svn-id: r49389
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/detection.cpp11
-rw-r--r--engines/sci/resource.cpp10
2 files changed, 20 insertions, 1 deletions
diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp
index dbd65c7aaa..aba2b0b74e 100644
--- a/engines/sci/detection.cpp
+++ b/engines/sci/detection.cpp
@@ -464,7 +464,16 @@ const ADGameDescription *SciMetaEngine::fallbackDetect(const Common::FSList &fsl
s_fallbackDesc.platform = Common::kPlatformAmiga;
// Determine the game id
- Common::String gameId = convertSierraGameId(resMan->findSierraGameId(), &s_fallbackDesc.flags, resMan);
+ Common::String sierraGameId = resMan->findSierraGameId();
+
+ // If we don't have a game id, the game is not SCI
+ if (sierraGameId.empty()) {
+ SearchMan.remove("SCI_detection");
+ delete resMan;
+ return 0;
+ }
+
+ Common::String gameId = convertSierraGameId(sierraGameId, &s_fallbackDesc.flags, resMan);
strncpy(s_fallbackGameIdBuf, gameId.c_str(), sizeof(s_fallbackGameIdBuf) - 1);
s_fallbackGameIdBuf[sizeof(s_fallbackGameIdBuf) - 1] = 0; // Make sure string is NULL terminated
s_fallbackDesc.gameid = s_fallbackGameIdBuf;
diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp
index 8f4fd64d90..11d9492ad5 100644
--- a/engines/sci/resource.cpp
+++ b/engines/sci/resource.cpp
@@ -1935,6 +1935,10 @@ bool ResourceManager::hasSci1Voc900() {
reg_t ResourceManager::findGameObject(bool addSci11ScriptOffset) {
Resource *script = findResource(ResourceId(kResourceTypeScript, 0), false);
+
+ if (!script)
+ return NULL_REG;
+
int extraBytes = 0;
if (getSciVersion() == SCI_VERSION_0_EARLY || getSciVersion() >= SCI_VERSION_1_1)
extraBytes = 2;
@@ -1966,8 +1970,14 @@ Common::String ResourceManager::findSierraGameId() {
nameSelector += 5;
}
+ if (!heap)
+ return "";
+
int16 gameObjectOffset = findGameObject(false).offset;
+ if (!gameObjectOffset)
+ return "";
+
// Seek to the name selector of the first export
byte *seeker = heap->data + READ_UINT16(heap->data + gameObjectOffset + nameSelector * 2);
Common::String sierraId;