aboutsummaryrefslogtreecommitdiff
path: root/engines/sword2/resman.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sword2/resman.cpp')
-rw-r--r--engines/sword2/resman.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/engines/sword2/resman.cpp b/engines/sword2/resman.cpp
index 81d74f355b..fa9c396ef3 100644
--- a/engines/sword2/resman.cpp
+++ b/engines/sword2/resman.cpp
@@ -302,6 +302,8 @@ byte *ResourceManager::openResource(uint32 res, bool dump) {
readCluIndex(cluFileNum, file);
}
+ assert(_resFiles[cluFileNum].entryTab);
+
uint32 pos = _resFiles[cluFileNum].entryTab[actual_res * 2 + 0];
uint32 len = _resFiles[cluFileNum].entryTab[actual_res * 2 + 1];
@@ -474,15 +476,18 @@ void ResourceManager::readCluIndex(uint16 fileNum, Common::File *file) {
file->seek(table_offset);
assert((tableSize % 8) == 0);
- _resFiles[fileNum].entryTab = (uint32*)malloc(tableSize);
+ _resFiles[fileNum].entryTab = (uint32 *)malloc(tableSize);
_resFiles[fileNum].numEntries = tableSize / 8;
+
+ assert(_resFiles[fileNum].entryTab);
+
file->read(_resFiles[fileNum].entryTab, tableSize);
if (file->eos() || file->err())
error("unable to read index table from file %s", _resFiles[fileNum].fileName);
#ifdef SCUMM_BIG_ENDIAN
for (int tabCnt = 0; tabCnt < _resFiles[fileNum].numEntries * 2; tabCnt++)
- _resFiles[fileNum].entryTab[tabCnt] = FROM_LE_32(_resFiles[fileNum].entryTab[tabCnt]);
+ _resFiles[fileNum].entryTab[tabCnt] = FROM_LE_32(_resFiles[fileNum].entryTab[tabCnt]);
#endif
}