From e5ec399c55a616379c9c9c400d1eb96b24e9f15c Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Fri, 15 Oct 2010 06:12:23 +0000 Subject: SWORD2: Fix some code analysis warnings (bug #3087857) svn-id: r53467 --- engines/sword2/resman.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/sword2/resman.cpp') diff --git a/engines/sword2/resman.cpp b/engines/sword2/resman.cpp index 81d74f355b..1b2411a404 100644 --- a/engines/sword2/resman.cpp +++ b/engines/sword2/resman.cpp @@ -474,7 +474,7 @@ 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; file->read(_resFiles[fileNum].entryTab, tableSize); if (file->eos() || file->err()) @@ -482,7 +482,7 @@ void ResourceManager::readCluIndex(uint16 fileNum, Common::File *file) { #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 } -- cgit v1.2.3 From 10bd159d0dfe4238c4df379b1740d098ce8dfa31 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Fri, 15 Oct 2010 19:08:56 +0000 Subject: SWORD2: Add assert()s prompted by code analysis warnings. See bug #3087857. svn-id: r53509 --- engines/sword2/resman.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'engines/sword2/resman.cpp') diff --git a/engines/sword2/resman.cpp b/engines/sword2/resman.cpp index 1b2411a404..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]; @@ -476,6 +478,9 @@ void ResourceManager::readCluIndex(uint16 fileNum, Common::File *file) { assert((tableSize % 8) == 0); _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); -- cgit v1.2.3