diff options
Diffstat (limited to 'engines/tsage/resources.cpp')
-rw-r--r-- | engines/tsage/resources.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/engines/tsage/resources.cpp b/engines/tsage/resources.cpp index 676d319ba9..6d2c6b5837 100644 --- a/engines/tsage/resources.cpp +++ b/engines/tsage/resources.cpp @@ -66,7 +66,9 @@ uint16 MemoryManager::allocate(uint32 size) { byte *MemoryManager::allocate2(uint32 size) { uint32 idx = allocate(size); - return lock(idx); + byte *result = lock(idx); + Common::set_to(result, result + size, 0); + return result; } byte *MemoryManager::lock(uint32 handle) { @@ -235,8 +237,13 @@ byte *TLib::getResource(uint16 id, bool suppressErrors) { uint16 ctrCurrent = 0x102, ctrMax = 0x200; uint16 word_48050 = 0, currentToken = 0, word_48054 =0; byte byte_49068 = 0, byte_49069 = 0; - DecodeReference table[0x1000]; - for (int i = 0; i < 0x1000; ++i) { + + const uint tableSize = 0x1000; + DecodeReference *table = (DecodeReference *)malloc(tableSize * sizeof(DecodeReference)); + if (!table) + error("[TLib::getResource] Cannot allocate table buffer"); + + for (uint i = 0; i < tableSize; ++i) { table[i].vByte = table[i].vWord = 0; } Common::Stack<uint16> tokenList; @@ -300,6 +307,8 @@ byte *TLib::getResource(uint16 id, bool suppressErrors) { } } + free(table); + assert(bytesWritten == re->uncompressedSize); delete compStream; return dataOut; |