diff options
| author | Filippos Karapetis | 2008-02-27 15:11:16 +0000 |
|---|---|---|
| committer | Filippos Karapetis | 2008-02-27 15:11:16 +0000 |
| commit | a7269c6009eb6c871037c4c1ae1c71e6f8b139c6 (patch) | |
| tree | 204597fe7215842bf928db85bc0acde6824dcf71 | |
| parent | 6f2215753c6142ffb4130585393b0330c739c133 (diff) | |
| download | scummvm-rg350-a7269c6009eb6c871037c4c1ae1c71e6f8b139c6.tar.gz scummvm-rg350-a7269c6009eb6c871037c4c1ae1c71e6f8b139c6.tar.bz2 scummvm-rg350-a7269c6009eb6c871037c4c1ae1c71e6f8b139c6.zip | |
Fix for bug #1895205 - "IHNM: end game text/caption error"
svn-id: r30985
| -rw-r--r-- | engines/saga/saga.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/engines/saga/saga.cpp b/engines/saga/saga.cpp index 33d78a2e11..8200526ecf 100644 --- a/engines/saga/saga.cpp +++ b/engines/saga/saga.cpp @@ -315,6 +315,7 @@ int SagaEngine::go() { void SagaEngine::loadStrings(StringsTable &stringsTable, const byte *stringsPointer, size_t stringsLength) { uint16 stringsCount; size_t offset; + size_t prevOffset = 0; int i; if (stringsLength == 0) { @@ -334,6 +335,13 @@ void SagaEngine::loadStrings(StringsTable &stringsTable, const byte *stringsPoin scriptS.seek(0); while (i < stringsCount) { offset = scriptS.readUint16(); + // In some rooms in IHNM, string offsets can be greater than the maximum value than a 16-bit integer can hold + // We detect this by checking the previous offset, and if it was bigger than the current one, an overflow + // occured (since the string offsets are sequential), so we're adding the missing part of the number + // Fixes bug #1895205 - "IHNM: end game text/caption error" + if (prevOffset > offset) + offset += 65536; + prevOffset = offset; if (offset == stringsLength) { stringsCount = i; stringsTable.strings = (const char **)realloc(stringsTable.strings, stringsCount * sizeof(*stringsTable.strings)); |
