diff options
Diffstat (limited to 'sword2/memory.cpp')
-rw-r--r-- | sword2/memory.cpp | 3 |
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); |