aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorbjörn Andersson2004-06-10 06:33:11 +0000
committerTorbjörn Andersson2004-06-10 06:33:11 +0000
commit0d193e87ce9fd590ab6e87e098776b8caac77635 (patch)
tree1434c13d334d8b00424de526b4e98050ee797016
parentc63cc7c7d12826a5e3d5607ddef32e05f9e2a998 (diff)
downloadscummvm-rg350-0d193e87ce9fd590ab6e87e098776b8caac77635.tar.gz
scummvm-rg350-0d193e87ce9fd590ab6e87e098776b8caac77635.tar.bz2
scummvm-rg350-0d193e87ce9fd590ab6e87e098776b8caac77635.zip
Added another assert(). I'm hunting - unsuccessfully so far - for a
reproducable crash where an invalid pointer is decoded. Strangely, I never saw it being encoded... Oh well, I'll find it eventually. svn-id: r13951
-rw-r--r--sword2/memory.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/sword2/memory.cpp b/sword2/memory.cpp
index 4fe2178a77..c8f0087996 100644
--- a/sword2/memory.cpp
+++ b/sword2/memory.cpp
@@ -101,12 +101,13 @@ int32 MemoryManager::encodePtr(byte *ptr) {
assert(id <= 0x03ff);
assert(offset <= 0x003fffff);
+ assert(offset < _memBlocks[id].size);
return (id << 22) | (ptr - _memBlocks[id].ptr);
}
byte *MemoryManager::decodePtr(int32 n) {
- int16 id = (n >> 22) & 0x03ff;
+ uint32 id = (n & 0xffc00000) >> 22;
uint32 offset = n & 0x003fffff;
assert(_memBlocks[id].ptr);